I have CORS issue and spend a lot of time trying to figure it out, so I decide to ask a question here. I have keystone app on a subdomain to the domain where is my angular 5 app. On localhost everything works ok but, but when I put my files to the server and try open my angular app I get this error:
Failed to load http://xxxxxxxx.com/label: Request header field params is not allowed by Access-Control-Allow-Headers in preflight response.
I have added this lines to my keystone.js file:
keystone.set('cors allow origin', true);
keystone.set('cors allow methods', true);
keystone.set('cors allow headers', true);
And this line in routes/index.js:
app.all('/*', keystone.middleware.cors);
And I tried add this to routes/index.js:
app.options('/*', function(req, res) {
res.header("Access-Control-Allow-Credentials", "true");
res.header('Access-Control-Allow-Methods', 'GET,POST');
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.sendStatus(200);
});
But I still get the same error. Any suggestions how to fix that?