Skip to content Skip to sidebar Skip to footer

React Connecting To Node Cors Preflight Failure

Node Server var app = express(); app.use(function(req, res, next) { res.header('Access-Control-Allow-Credentials', true); res.header('Access-Control-Allow-Origin'

Solution 1:

have you ever tried express/cors i recently also had problem with access allow origin then i download express/cors from

npm install cors

then add in your program

var express = require('express')
var cors = require('cors')
var app = express()

app.use(cors())

app.get('/products/:id', function (req, res, next) {
  res.json({msg: 'This is CORS-enabled for all origins!'})
})

app.listen(80, function () {
  console.log('CORS-enabled web server listening on port 80')
})

you can also see other method to use cors in [link]https://github.com/expressjs/cors

Post a Comment for "React Connecting To Node Cors Preflight Failure"