Skip to content

Instantly share code, notes, and snippets.

@dswwsd
Last active August 15, 2017 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dswwsd/b17ec2fc347a25f29e6e89fa8c8e9044 to your computer and use it in GitHub Desktop.
Save dswwsd/b17ec2fc347a25f29e6e89fa8c8e9044 to your computer and use it in GitHub Desktop.
Response response = context.response();
response.setHeader("Access-Control-Allow-Origin", "*");
//Handle preflight requests
if(context.request().method().equals("OPTIONS")) {
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization, X-Auth-Token");
response.setHeader("Access-Control-Allow-Credentials", "true");
return delegate.call(context);
}
response.setHeader("Access-Control-Allow-Headers","X-Requested-With, Content-Type, X-Auth-Token");
return delegate.call(context);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment