1

I got this:

XMLHttpRequest cannot load http://62.244.120.89:9000/api/v2/content/categories/sl_1-main/. Request header field HTTP_LANGUAGE_CODE is not allowed by Access-Control-Allow-Headers in preflight response.

I found question: Request header field Access-Control-Allow-Headers is not allowed by itself in preflight response

In one answer they suggest to add response headers

response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
response.setHeader("Access-Control-Allow-Headers", "Access-Control-Allow-Headers, Origin,Accept, X-Requested-With,

Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");

Do I do this on server on client ?

user2950593
  • 9,233
  • 15
  • 67
  • 131
  • 1
    CORS is the server.... not the client – epascarello Aug 07 '17 at 18:22
  • Server has to answer to preflight request (`OPTIONS`) with all non-default details, incl. the headers that are not "CORS-safelisted request headers". See https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS and https://fetch.spec.whatwg.org/#cors-safelisted-request-header. – medik Aug 07 '17 at 22:27

1 Answers1

3

You would set the response headers in the server that you are making the request to.

Link0352
  • 201
  • 1
  • 7