Created
August 26, 2020 14:57
-
-
Save RolandWarburton/f34877d08b592485b02b8a74af5d5b7c to your computer and use it in GitHub Desktop.
backup cors. for when all else fails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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