I'm developing a server at Node js and my front-end at Angularjs, but I'm getting an error when I try to make a request from my front-end:
XMLHttpRequest cannot load http://localhost:8085/server/authenticate/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.
My code at my server.js
app.use(function(req,res,next){ res.setHeader('Access-Control-Allow-Oringin','*'); res.setHeader('Access-Control-Allow-Methods','GET,POST,OPTIONS'); res.setHeader('Access-Control-Allow-Headers','X-Requested-With,content-type,Authorization,accept'); if (req.method === 'OPTIONS'){ res.statusCode = 200; return res.end(); } else{ return next(); } }); Any suggestions?
NOTE: back-end and front-end are not at the same port, I'm trying to make it work as a CROSS-Origin resourse.
Access-Control-Allow-Oringinis not a CORS header :) The error message is indeed correct thatAccess-Control-Allow-Originis not being set on the response.