I have setup CORS on my node.js server on port 5000 as follows:
var app = express();
app.use(cors()); //normal CORS
app.options(\'*\', cors()); //preflight
This is the code I am using. It is located in my app.js file
app.all("/*", function (req, res, next) {
res.header("Access-Control-Allow-Origin", req.headers.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', 'Content-Type,Accept,X-Access-Token,X-Key,Authorization,X-Requested-With,Origin,Access-Control-Allow-Origin,Access-Control-Allow-Credentials');
if (req.method === 'OPTIONS') {
res.status(200).end();
} else {
next();
}
});