如何为RESTEasy预检请求设置Access-Control-Allow-Origin?

时间:2016-10-12 16:59:16

标签: cors resteasy

服务器端代码(我的RESTEasy服务器在http://myServer上运行):

预检请求处理程序:

@PermitAll
@OPTIONS
@Path("/uploadFile")
public Response preFlightUploadFile() throws Exception {
    logger.info("preFlightUploadFile");
    return Response.ok()
            .header("Access-Control-Allow-Origin", "*")
            .header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
            .header("Access-Control-Allow-Headers", "accept, Cache-Control, content-type, x-requested-with")
            .build();
}

预检回复:

Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Origin: http://myServer
Content-Length: 0
Date: Wed, 12 Oct 2016 16:16:16 GMT

为什么回复被覆盖?

我将不胜感激。

1 个答案:

答案 0 :(得分:0)

显然,myServer中有一些过滤器覆盖了我的设置.. 我改变了,我的代码工作了..