Im trying to interact angular 2 with node js and below is my cors headers configured in index.js of nodejs
app.use(function(req, res, next) {
res.setHeader("Access-Control-Allow-Methods", "POST, PUT, OPTIONS, DELETE, GET");
res.header("Access-Control-Allow-Origin", "http://localhost:4200");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
//res.header("Access-Control-Allow-Credentials", false);
next();
});
app.use(cors({ origin: 'http://localhost:4200' })); //If i use this it works
app.use(cors({ origin: '*' })); //But i want to keep it as *
I have not anywhere configured CORS nor set withCredentials to True, where is my setting wrong?