I've been struggling with this problem for a while now.
My Nuxt app and service are both hosted on Heroku. After ditching cors()
, I added the following code:
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", '*');
res.header("Access-Control-Allow-Credentials", true);
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header("Access-Control-Allow-Headers", 'Origin,X-Requested-With,Content-Type,Accept,content-type,application/json');
next();
});
Even though I can see in my browser's DevTools that the server is sending the correct information, I still encounter this error:
https://i.stack.imgur.com/BFgGe.png
Since these are test campaigns, privacy is not a concern for me right now.
What could be the issue? The server clearly responds with the correct CORS policy, but suddenly my Nuxt apps refuse to communicate due to CORS problems when making calls.
I've dealt with many bugs before, but I'm completely lost on this one. Any advice or insights would be greatly appreciated. Thank you!