Skip to content

Instantly share code, notes, and snippets.

@RolandWarburton
Created August 26, 2020 14:57
Show Gist options
  • Save RolandWarburton/f34877d08b592485b02b8a74af5d5b7c to your computer and use it in GitHub Desktop.
Save RolandWarburton/f34877d08b592485b02b8a74af5d5b7c to your computer and use it in GitHub Desktop.
backup cors. for when all else fails
app.use((req, res, next) => {
debug("running cors");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, COntent-Type, Accept, Authorization"
);
// Or drop a tactical nuke with
// res.header("Access-Control-Allow-Headers", "*");
if (req.method === "Options") {
res.header(
"Access-Control-Allow-Methods",
"PUT, POST, PATCH, DELETE, GET"
);
return res.status(200).json({});
}
next();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment