Skip to content

Instantly share code, notes, and snippets.

@aweiland
Created April 9, 2016 22:43
Show Gist options
  • Select an option

  • Save aweiland/3406db0ae70e043d67a3bc09dc195e81 to your computer and use it in GitHub Desktop.

Select an option

Save aweiland/3406db0ae70e043d67a3bc09dc195e81 to your computer and use it in GitHub Desktop.

Revisions

  1. aweiland created this gist Apr 9, 2016.
    14 changes: 14 additions & 0 deletions Application.Java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    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, "/*");

    }