-
-
Save Querela/e33e58bd25eedfe55def03fa166137aa to your computer and use it in GitHub Desktop.
CORS in Dropwizard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void configureCors(Environment environment) { | |
final FilterRegistration.Dynamic cors = | |
environment.servlets().addFilter("CORS", CrossOriginFilter.class); | |
// Configure CORS parameters | |
cors.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*"); | |
cors.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Content-Type,Accept,Origin,Authorization"); | |
cors.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "OPTIONS,GET,PUT,POST,DELETE,HEAD"); | |
cors.setInitParameter(CrossOriginFilter.ALLOW_CREDENTIALS_PARAM, "true"); | |
// Add URL mapping | |
cors.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment