Answers for "node add header to preflight request"

1

express get request origin

app.use((req, res, next) => {
  const host = req.get('host');
  const origin = req.get('origin');
});
Posted by: Guest on August-27-2020
26

express js cors

var express = require('express')
var cors = require('cors')  //use this
var app = express()

app.use(cors()) //and this

app.get('/user/:id', function (req, res, next) {
  res.json({user: 'CORS enabled'})
})

app.listen(5000, function () {
  console.log('CORS-enabled web server listening on port 5000')
})
Posted by: Guest on November-13-2020

Code answers related to "node add header to preflight request"

Code answers related to "Javascript"

Browse Popular Code Answers by Language