Created
July 15, 2016 19:05
-
-
Save DWboutin/62b0ffe5cf24850a00a185c840370347 to your computer and use it in GitHub Desktop.
Express cross-origin options
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
export default function allowCrossOrigin(req, res, next) { | |
res.header('Access-Control-Allow-Origin', '*'); | |
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'); | |
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); | |
if ('OPTIONS' === req.method) { | |
res.sendStatus(200); | |
} else { | |
next(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment