Nodejs express, Heroku CORS

Hi I worked out that it was due to Heroku will only install packeges from your dependancies

And what I needed was in my devDependencies, so once I reinstalled as dependancies it worked!


Try to also allow the credentials:

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();
});

Edit:

Also if you want to make a local http call in your heroku app; change

private url = 'https://myserver.herokuapp.com/';

to

private url = '/';