Skip to content

Instantly share code, notes, and snippets.

@Fiasko99
Last active February 1, 2021 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fiasko99/4fff36a2403023f4d9eb7406629c093a to your computer and use it in GitHub Desktop.
Save Fiasko99/4fff36a2403023f4d9eb7406629c093a to your computer and use it in GitHub Desktop.
// Настройка CORS
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, Authorization"
);
res.header(
"Access-Control-Allow-Methods",
"GET, PATCH, PUT, POST, DELETE, OPTIONS"
);
next();
});
app.use((req, res, next) => {
res.set("Access-Control-Allow-Origin", 'http://localhost:8080')
res.set("Access-Control-Allow-Headers", 'Content-type')
res.set("Access-Control-Allow-Methods", 'GET, POST')
res.set("Access-Control-Allow-Credentials", true)
res.removeHeader('X-Powered-By')
next()
})
app.use(cors())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment