Simple thing will be to enable Core middleware, like the below
const cors = require('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();
});
app.get('/', cors(), (request, response) => {
response.send('OK, am up!')
})
References:
https://flaviocopes.com/express-cors/
const cors = require('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();
});
app.get('/', cors(), (request, response) => {
response.send('OK, am up!')
})
References:
https://flaviocopes.com/express-cors/
No comments:
Post a Comment