I've spent a couple hours trying to figure this out...
app.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', "*");
res.header('Access-Control-Allow-Methods','GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type');
next();
});
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
});
Didn't work for me... I have this in my servers app.js right after the requires at the top.
Also tried the npm install cors and app.use(cors()). Didn't work either.
Why would I be experiencing this issue? I am using the express-generator (npm install express-generator)
app.use(cors())
right afterapp = express()