Skip to content

Instantly share code, notes, and snippets.

@amessinger
Created March 1, 2013 15:46
Show Gist options
  • Save amessinger/5065501 to your computer and use it in GitHub Desktop.
Save amessinger/5065501 to your computer and use it in GitHub Desktop.
A policy to allow CORS responses on your sailsjs-based (or express) API.
module.exports = function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
}
@pierredewilde
Copy link

module.exports = function (req, res, next) {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type');
    res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS, HEAD');
    next();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment