Skip to content

Instantly share code, notes, and snippets.

@rafaelbrizola
Created August 10, 2020 09:11
Show Gist options
  • Save rafaelbrizola/1a0359ba5f0c58b4ad0a76f81cd26387 to your computer and use it in GitHub Desktop.
Save rafaelbrizola/1a0359ba5f0c58b4ad0a76f81cd26387 to your computer and use it in GitHub Desktop.
@Override
public void run(MyConfiguration configuration, Environment environment)
{
// Enable CORS headers
final FilterRegistration.Dynamic cors = environment.servlets().addFilter("CORS", CrossOriginFilter.class);
// Configure CORS parameters
cors.setInitParameter("allowedOrigins", configuration.getAllowedOrigin());
cors.setInitParameter("allowedHeaders", "X-Requested-With,Content-Type,Accept,Origin");
cors.setInitParameter("allowedMethods", "OPTIONS,GET,PUT,POST,DELETE,HEAD");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment