title: Angular Interceptor: headers added in the request not set properly, can't fetch them from the API
body: <p>I'm trying to add some custom headers in my angular interceptor as follow:</p>
  <pre><code>@Injectable()
  export class HttpJwtAuthInterceptor implements HttpInterceptor {
  
    constructor() {}
  
    intercept(request: HttpRequest&lt;unknown&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;unknown&gt;&gt; {
      localStorage.setItem('token', 'qsdfqsdfqsdfqsdf');
      if (localStorage.getItem('cuid') &amp;&amp; localStorage.getItem('token')) {
        request = request.clone({
          setHeaders: {
            'sm_universalid':'blablabla',
            Authorization: `Bearer ${localStorage.getItem('token')}`,
          },
        });
      }
  
  
  
      return next.handle(request);
    }
  }
  </code></pre>
  <p>The above interceptor was added into providers property in <strong>app.module.ts</strong>:</p>
  <pre><code>  providers: [
      {
        provide: HTTP_INTERCEPTORS,
        useClass: HttpJwtAuthInterceptor,
        multi: true,
      },
      { provide: BASE_PATH, useValue: environment.apiUrl },
    ],
  </code></pre>
  <p>In my spring boot application, I am adding a filter to check if the headers are received, if not it throw an exception:</p>
  <pre><code>String cuid = request.getHeader(SM_UNIVERSAL_ID);
  if (cuid == null || cuid.isEmpty()) {
      log.error(&quot;Failed authentication: cuid header not found in the request or it is empty&quot;);
      throw new FailedAuthenticationException(&quot;cuid header not found in the request or it is empty:&quot;+cuid);
  }
  </code></pre>
  <p>Unfortunately the filter can't find the added headers, I tried to log the list of headers received and I found that they were added as value for <strong>access-control-request-headers</strong>  header:
  <a href="https://i.stack.imgur.com/s0R81.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s0R81.png" alt="enter image description here" /></a></p>
  <p>How can I get those headers separately? and why they were added into <strong>access-control-request-headers</strong> header?</p>
  <p>Bellow a snapshot of my spring security class config (the header filter is applied there):</p>
  <pre><code> @Configuration
  @EnableWebSecurity
  @Slf4j
  @RequiredArgsConstructor
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
      private final HeaderVerificationFilter headerVerificationFilter;
      private final JwtAuthorizationFilter jwtAuthorizationFilter;
      private final JwtAuthEntryPoint jwtAuthenticationEntryPoint;
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          //csrf is disabled because we are not using cookies
          http.csrf().disable();
  
          // No session will be created or used by spring security
          http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
  
          //Entry points
          http.formLogin().loginProcessingUrl(&quot;/api/login&quot;).permitAll()
                  //Disallow everything else
                  .and().authorizeRequests().anyRequest().authenticated();
  
          //if a user try to access a resource without having enough permissions
          http.exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint);
  
          // Apply Header and JWT filters
          http.apply(new JwtTokenFilterConfigurer(headerVerificationFilter, jwtAuthorizationFilter, jwtAuthenticationEntryPoint));
      }
  
  
      @Bean
      public PasswordEncoder passwordEncoder() {
          return new BCryptPasswordEncoder(12);
      }
  
      @Override
      public void configure(WebSecurity web) throws Exception {
          // Allow swagger to be accessed without authentication
          web.ignoring().antMatchers(&quot;/v2/api-docs&quot;)//
                  .antMatchers(&quot;/swagger-resources/**&quot;)//
                  .antMatchers(&quot;/swagger-ui.html&quot;)//
                  .antMatchers(&quot;/configuration/**&quot;)//
                  .antMatchers(&quot;/webjars/**&quot;)//
                  .antMatchers(&quot;/public&quot;);
      }
  
      @Override
      @Bean
      public AuthenticationManager authenticationManagerBean() throws Exception {
          return authenticationManager();
      }
  }
  </code></pre>