So im working on some Express.js app. for a website and i am tryna manage CORS but it wont work anyway. i tried both CORS package and the manual headers. could anyone please help me?
app.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); res.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE", "OPTIONS"); next(); });
app.options("*", (request, reply) => reply.status(204).send())
I tried as stated above, got error in web console about CORS ( expecting it to work )
user24894040 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.