Answers for "set allow cross origin in node js api"

5

allow cross origin node

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();
});
Posted by: Guest on April-23-2020
0

add access-control-allow-origin in node js

// Install cors package: npm install cors
const express = require("express");
const app = express();
const cors = require('cors');
app.use(cors());
// your http request should work after this
Posted by: Guest on October-14-2021

Code answers related to "set allow cross origin in node js api"

Code answers related to "Javascript"

Browse Popular Code Answers by Language