Skip to content

Instantly share code, notes, and snippets.

@lbrenman
Created March 4, 2015 16:29
Show Gist options
  • Save lbrenman/63dbd13fab70cb6c33ca to your computer and use it in GitHub Desktop.
Save lbrenman/63dbd13fab70cb6c33ca to your computer and use it in GitHub Desktop.
Overcoming Cross Site Scripting issue with Node Apps
// initialize app
function start(app, express) {
app.use(express.favicon(__dirname + '/public/images/favicon.ico')); //set favicon
var allowCrossDomain = function(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', 'Content-Type, Authorization, x-requested-with, X-Titanium-Id');
res.header('Access-Control-Allow-Credentials', 'true');
next();
};
app.use(allowCrossDomain);
}
// release resources
function stop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment