I'm new to node and need some help.
I'm getting: Access to XMLHttpRequest at 'http://localhost:3000/api/auth/signin' from origin 'http://localhost:4200' has been blocked by CORS policy:
my angular app is launching from http://localhost:4200
And I'm making an api request (which works on postman) to http://localhost:3000/api/auth/signin
but I'm getting CORS errors.
In my node server.js, I have the following configured:
app.use(function (req, res, next) {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.setHeader('Access-Control-Allow-Methods', "GET, POST, PATCH, DELETE, OPTIONS");
next();
});
And I can post data using postman to: localhost:3000/api/auth/signin