GWT:使用反向代理在开发模式下请求生成器
我在 GWT 上使用请求生成器时遇到问题。
我正在使用配置了反向代理的本地服务器(Apache)(因此我在进行跨域调用时没有问题)。当我在生产模式下运行 GWT 项目时,调用效果很好。
然而,在开发模式中,我在这样做时遇到了麻烦 - 似乎我发出的每个 POST 请求都以某种方式变成了 OPTIONS 请求,所以我永远不会得到我想要的响应。
现在我很茫然。如果调用在生产模式下工作正常,那么问题不在于我的 Apache 配置,也不在于我的 GWT 代码,对吗?我假设问题出在开发模式配置上,但我找不到任何相关信息。我的项目的其余部分在两种模式下都运行良好。
I'm having a problem using the Request Builder on GWT.
I'm using a local server (Apache) configured with a Reverse Proxy (so I don't have problems making cross domain calls). When I run my GWT project in production mode, the calls are made just fine.
However, in development mode, I'm having trouble doing so - it seems that every POST request I make is somehow turned into a OPTIONS one, so I never get the response I want.
Right now I'm quite at loss. If the calls work fine on production mode, then the problem isn't with my Apache configuration nor with my GWT code, right? I'm assuming that the problem is with the development mode configuration, but I can't find any information on that. The rest of my project works fine on both modes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您没有在服务器
- 中运行 DevMode noserver
模式,那么您的浏览器只是遵循CORS,强制使用OPTIONS
检查跨源在实际执行之前允许 POST
。在 IE 中尝试一下,您会遇到同源策略(因为 IE 没有在
XMLHttpRequest
上实现 CORS,但在 GWT 不尝试处理的特定于 IE 的XDomainRequest
上实现 CORS – 对于某些 [跨源请求] 来说,运行时开销太大这是很少使用的,每个人都认为 IE 应该修复 –)。If you're not running DevMode off your server in
-noserver
mode, then your browser is simply following CORS, which mandates checking withOPTIONS
if a cross-originPOST
is allowed before actually doing it.Try it in IE and you'll hit the Same-Origin Policy instead (as IE doesn't implement CORS on
XMLHttpRequest
, but on a IE-specificXDomainRequest
that GWT doesn't try to deal with –too much runtime overhead for something [cross-origin requests] that's very rarely used and that everyone thinks IE should fix instead–).