Express wildcard origin snippet
Posted on July 23, 2020
Here for future reference, assuming a typical express
app, the middleware to accept any origin for every requests:
app.use(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()
})
You need to install cors
, though.
Source here.