Overcoming CORS Issues

suggest change

Set these headers on the response. Access-Control-Allow-Origin: * cannot be combined with credentials; browsers reject that pair. Name the calling origin when the browser should send cookies.

// Origin you want to allow. Do not use '*' when credentials are enabled.
response.setHeader('Access-Control-Allow-Origin', 'https://example.com');

// Request methods you wish to allow
response.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');

// Request headers you wish to allow
response.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');

// Set to true if you need the website to include cookies in the requests sent
// to the API (e.g. in case you use sessions)
response.setHeader('Access-Control-Allow-Credentials', 'true');

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents