title: cors enable in Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response
body: <p>I'm using spring boot service for backend and and angular 6 for frontend.</p>
  
  <p>In spring boot i enabled cors using.</p>
  
  <pre><code> @Override
   public void addCorsMappings(CorsRegistry registry) {
      registry.addMapping("/interview/**").allowedOrigins("*");
   }
  </code></pre>
  
  <p>and i'm using intercepter for each service.</p>
  
  <p>in frontend calling service:</p>
  
  <pre><code>headers = new Headers();
  constructor(private http: Http, private logger: MLogger) {
      this.headers.set("Access-Control-Allow-Origin", "*");
      this.headers.set( 'Content-Type', 'application/json',);
      this.headers.set( 'Accept', '*');
      this.headers.set( 'sessionId', DataService.sessionId);
   }
   private options = new RequestOptions({ headers: this.headers});
    interviewCommand: InterviewCommand;
    getInterviewDetails(data: any): Promise&lt;any&gt; {
      const serviceURL = environment.startInterviewURL;
      return this.http
        .post(serviceURL,data, this.options)
        .toPromise()
        .then(
          interviewCommand =&gt; {
            //doing some stuff
            }
          })
        .catch(this.handleInterviewCommandError);
    }
  </code></pre>
  
  <p>I'm getting below exception if using intercepter. Without using interepter i'm not getting cors error..</p>
  
  <blockquote>
    <p>Failed to load <a href="http://localhost:7070/example/myservice" rel="nofollow noreferrer">http://localhost:7070/example/myservice</a>: Request header
    field Access-Control-Allow-Origin is not allowed by
    Access-Control-Allow-Headers in preflight response.</p>
  </blockquote>
  
  <p>In my intercepter i added below thing:</p>
  
  <pre><code>if (request.getMethod().equals("OPTIONS")) {
          response.setHeader("Access-Control-Allow-Origin", "*");
          response.setHeader("Access-Control-Allow-Origin-Methods", "GET, POST, OPTIONS");
          response.setHeader("Access-Control-Allow-Headers", "Authorization, Content-Range, Content-Disposition, Content-Description,Origin, X-Requested-With");
          response.setHeader("Access-Control-Expose-Headers", "*");
            response.setHeader("Access-Control-Allow-Credentials", "true");
            response.setHeader("Access-Control-Max-Age", "4800");
          }
  </code></pre>