Skip to content

Instantly share code, notes, and snippets.

@h4ck4life
Forked from doapp-ryanp/gist:6011897
Created November 13, 2013 04:53
Show Gist options
  • Save h4ck4life/7443920 to your computer and use it in GitHub Desktop.
Save h4ck4life/7443920 to your computer and use it in GitHub Desktop.
this.before(function(){
var res = this.response;
if ('OPTIONS' == this.request.method) {
res.setHeaders(200,{
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Requested-With',
'Access-Control-Max-Age': 5184000 //2 months
});
res.finish();
return;
}
else {
this.response.resp.setHeader('Access-Control-Allow-Origin', '*');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment