I solved it without adding new packages, just added this line
res.header("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE");
Please note that I have allowed methods, separated by commas inside the same line. The full function looks like this:
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", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
next();
});
source
share