Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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')
})
 
PREVIOUS NEXT
Tagged: #express #js #cors
ADD COMMENT
Topic
Name
2+8 =