POST REST API调用不适用于Chrome浏览器,但适用于IE浏览器

时间:2019-02-11 12:45:10

标签: java rest google-chrome tomcat tomcat8

我们有一个Web应用程序,其UI托管在一台主机上的一台Apache服务器上,后端REST API服务托管于另一台主机上的tomcat服务器上。 对于UI:使用Node.js并将其托管在Apache上 对于API:Java 8,使用Spring REST,而war文件托管在tomcat 8.5.32上

问题:

在使用Chrome浏览器(版本:71.0.3578.80)进行所有POST API调用时,服务器会以错误代码403(禁止)进行响应,但是对于IE浏览器(版本11.0.105),相同的POST API会返回状态为200的响应(成功)。 对于所有POST请求,都会观察到上述行为。

以下是Chrome浏览器的请求和响应标头:

请求标头:

Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Content-Length: 6559
Content-Type: application/json
Cookie: <cookies>
Host: <myhost>.com
Origin: https://<myhost>.com
Referer: https://<myhost>.com/beta/
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36

响应标题:

Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: https://<myhost>.com
Connection: Keep-Alive
Content-Length: 0
Content-Type: text/plain
Date: Mon, 11 Feb 2019 11:49:25 GMT
Keep-Alive: timeout=5, max=95
Server: Apache
Strict-Transport-Security: max-age=31536000

API调用常规详细信息:

Request URL: https://<myhost>.com/services/v1/settings
Request Method: POST
Status Code: 403 
Remote Address: <ip address>:443
Referrer Policy: no-referrer-when-downgrade

请求有效载荷:

{"userId":"test", "someFlag": "someValue"}

您能帮助您了解上述标题中缺少的内容吗?

发现:

如果我们从8.5.32版本恢复到tomcat版本8.5.29,则POST API请求调用在所有浏览器上都可以正常工作。

我还发现针对Tomcat 8.5.32的修复已完成 https://tomcat.apache.org/security-8.html#Fixed_in_Apache_Tomcat_8.5.32:低:CORS过滤器的默认设置不安全CVE-2018-8014,这可能会导致此问题,但我无法弄清楚确切的问题以及我应该怎么做一些标头更改才能使此POST请求在Chrome上正常工作浏览器。

0 个答案:

没有答案
相关问题