Skip to content

Instantly share code, notes, and snippets.

@jdaudier
Forked from Unitech/CORS
Last active August 29, 2015 14:06
Show Gist options
  • Save jdaudier/34565cc59656391d98b4 to your computer and use it in GitHub Desktop.
Save jdaudier/34565cc59656391d98b4 to your computer and use it in GitHub Desktop.
app.all('*', function (req, res, next) {
res.header("Access-Control-Allow-Origin", req.headers.origin);
res.header("Access-Control-Allow-Credentials", true);
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Authorization, Content-Length");
if (req.method == 'OPTIONS') {
return res.send(200);
}
return next();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment