title: CORS error and 403 response with JWT token
body: <p>I am trying to secure my Web Application via JWT token, but when I try to make a request from my Angular app (localhost:4200) to my Spring Boot app (localhost: 8080) I get the following error:</p>
  
  <p><a href="https://i.stack.imgur.com/BAA94.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BAA94.jpg" alt="enter image description here"></a></p>
  
  <p>From the message alone I can see that it is a <code>CORS</code> issue, the problem is that I've already enabled requests from different origin at my back-end, and here is the code for it:</p>
  
  <p>UPDATE: I've added OPTIONS into <code>allowedMethods()</code>, but the error remains the same.</p>
  
  <pre><code>@Configuration
  public class AppConfiguration {
  
  @Autowired
  private Environment env;
  
  @Bean
  public WebMvcConfigurer corsConfigurer() {
      return new WebMvcConfigurerAdapter() {
          @Override
          public void addCorsMappings(CorsRegistry registry) {
              registry.addMapping("/**")
                      .allowedOrigins("http://localhost:4200")
                      .allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD","OPTIONS")
                      .allowedHeaders("Content-Type", "Date", "Total-Count", "loginInfo")
                      .exposedHeaders("Content-Type", "Date", "Total-Count", "loginInfo")
                      .maxAge(3600);
          }
      };
  }
  </code></pre>
  
  <p>Here is the code from my Angular app as well :</p>
  
  <pre><code>    baseUrl = 'http://localhost:8080/api/';
  
      constructor(private http: Http) { }
  
  
      private postaviHeadere() : RequestOptions{
          let headers = new Headers();
  
          console.log("***************** Set Headers *****************");
          console.log('Getting token from local storage:');
          console.log(localStorage.getItem('jwt_token'))
          console.log("***********************************************");
  
          headers.append('JWT_TOKEN', localStorage.getItem('JWT_TOKEN'));
          let options = new RequestOptions({headers : headers});
          console.log(options);
          return options;
      }
  
      getUserByToken(): any {
          return this.http.get(this.baseUrl + 'user/secured', this.postaviHeadere())
      }
  </code></pre>