Dropwizard + Katharsis: Preflight (OPTIONS) returns 404

345 views Asked by At

I'm not sure how to configure these two libraries to correctly handle preflight requests (coming from Ember.js). Using the filter below works just fine with a standard Dropwizard/Jersey resource but does nothing when Katharsis is brought into play

        FilterRegistration.Dynamic filter = environment.servlets().addFilter("CORS", CrossOriginFilter.class);
        filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, environment.getApplicationContext().getContextPath() + "*");
        filter.setInitParameter(ALLOWED_METHODS_PARAM, "OPTIONS,GET,PUT,POST,DELETE,HEAD");
        filter.setInitParameter(ALLOWED_ORIGINS_PARAM, "*");
        filter.setInitParameter(ALLOWED_HEADERS_PARAM, "Content-Type," + "X-Requested-With," + "Accept," + "Origin," + "Authorization," + "Access-Control-Request-Method," + "Access-Control-Request-Headers," + "Access-Control-Allow-Origin");
        filter.setInitParameter(ALLOW_CREDENTIALS_PARAM, "true");
        filter.setInitParameter(ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*");

I can find a few examples of how people solve this using Spring, but I can't seem to adapt those to suit either.

Do I need to register something specific with Katharsis?

1

There are 1 answers

0
Christian Bongiorno On BEST ANSWER

OPTIONS is current not supported in Katharsis - it's a long requested feature.