Dropwizard + Katharsis:预检(OPTIONS)返回404

时间:2016-06-12 01:52:57

标签: java jersey dropwizard katharsis

我不确定如何配置这两个库来正确处理预检请求(来自Ember.js)。使用下面的过滤器可以很好地使用标准的Dropwizard / Jersey资源,但是当Katharsis进入游戏时什么都不做

        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, "*");

我可以找到一些人们如何使用Spring解决这个问题的例子,但我似乎也无法适应这些问题。

我是否需要注册与Katharsis特定的内容?

1 个答案:

答案 0 :(得分:0)

OPTIONS is current not supported in Katharsis - 这是一个长期要求的功能。