Skip to content Skip to sidebar Skip to footer

Response To Preflight Request Doesn't Pass Access Control Check In Nodejs

I cannot convince why I've encountered following error even I've added following code in NodeJS/ExpressJS. XMLHttpRequest cannot load http://localhost:9000/polymer/105724/apply.

Solution 1:

You also need to allow OPTIONS method. Browser sends an OPTIONS call before the actual call so if OPTIONS is not allowed next call will not be made.

res.setHeader('Access-Control-Allow-Methods', 'OPTIONS,GET,PUT,POST,DELETE');

Solution 2:

Allow OPTIONS and reply handling CORS HTTP headers to browser and await the request.

Post a Comment for "Response To Preflight Request Doesn't Pass Access Control Check In Nodejs"