I am trying to deal with CORS for my frontend. On my local host (development environment) the given cors works fine. but when I deploy application to heroku
it gives the given error.
Access to XMLHttpRequest at 'myHerokuURL' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
Here is the CORS that I am using.
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', '*');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With, Authorization, x-auth-token, content-type');
res.setHeader('Access-Control-Allow-Credentials', false);
next();
});