I’m writing an Ionic 2 application that communicates with a node server and mLab database on Heroku. Unfortunately when I try to send any request from the Ionic application I get errors that look like this.
Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access. The response had HTTP status code 503.
I have tried changing the headers around on the node heroku server
…
var cors = require(‘cors’);
…
app.use(cors());
…
app.use(function(req, res, next) {
res.header(“Access-Control-Allow-Origin”, “*”);
res.header(“Access-Control-Allow-Headers”, “Origin, X-Requested-With, Content-Type, Accept”);
next();
});
…
but no dice.
If you have any advice I would really appreciate it.