express headers code example

Example 1: set headers in express

response.header("Access-Control-Allow-Origin", "*");
    response.header("Access-Control-Allow-Headers", "Origin, X-Requested-With,Content-Type, Accept");
    response.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')

Example 2: http header express

app.get('/', (req, res) => {
  req.header('User-Agent')
})
// Use the Request.header() method to access
//one individual request header’s value

Example 3: node js http request express

npm install request@2.81.0

Example 4: in express how do you set the location header

res.location('/customers/' + inst._id)1

Tags:

Php Example