简体   繁体   English

JSON REST Get-Request 正在等待 Chrome/Firefox Tomcat 上的 CORS

[英]JSON REST Get-Request is pending with CORS on Tomcat for Chrome/Firefox

We have built a REST Backend with Jersey 1.9.1 on Tomcat 7.0.42 using the CORS Filter from http://software.dzhuvinov.com/cors-filter.html current version 1.9.我们使用来自http://software.dzhuvinov.com/cors-filter.html当前版本 1.9 的 CORS 过滤器在 Tomcat 7.0.42 上使用 Jersey 1.9.1 构建了一个 REST 后端。

When executing the following JS code from Chrome Version 31 or Firefox Version 26:从 Chrome 版本 31 或 Firefox 版本 26 执行以下 JS 代码时:

$.ajax({
  type: 'GET', contentType: 'application/json',
  url: 'http://tomcat.bailamos-salsa.ch/bailamossalsa/app-api/course',
  success: function(response) {
    alert(response);
  }
});

the preflight OPTIONS request returns with Code 200, but fro some devices the following GET request hangs and never returns.预检 OPTIONS 请求返回代码 200,但对于某些设备,以下 GET 请求挂起且永不返回。 We tested on Windows and OSX, for some devices it worked, but for other devices it did not work with the identical browser versions.我们在 Windows 和 OSX 上进行了测试,对于某些设备,它可以工作,但对于其他设备,它不能与相同的浏览器版本一起使用。

We debugged the CORS Filter on the server but could not identify any errors.我们在服务器上调试了 CORS 过滤器,但无法识别任何错误。

A test case can be found here: http://jsfiddle.net/d27Zb/可以在此处找到测试用例: http : //jsfiddle.net/d27Zb/

Any help is very appreciated, we are desperate.非常感谢任何帮助,我们很绝望。

For people who come across this in the future, the easiest way to debug this is to analyze the differences between systems.对于以后遇到这种情况的人来说,最简单的调试方法是分析系统之间的差异。 If you're using the same browser in multiple environments and it only works in some of them, it's probably a firewall issue.如果您在多个环境中使用相同的浏览器,并且它只能在其中一些环境中工作,则可能是防火墙问题。 As mentioned in the comments, turning off the CORS filter for their firewall on their Mac fixed the issue.正如评论中提到的,关闭他们 Mac 防火墙的 CORS 过滤器解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM