我最近一直在苦苦挣扎,只在Chrome中出现了一个超级奇怪的问题:由于我的API(NodeJS)位于不同的子域,所以我需要使用CORS从我的前端(EmberJS)访问它。 / p>
它工作得很好,但我经常(95%的时间)拥有非常慢的OPTIONS查询,将任何API调用延迟了大约3秒。
大部分时间都花在下载一个空的内容:
它变得更加怪异当我在另一个网站上尝试使用类似的架构时,遇到了完全相同的问题。
d:
我们在后端NodeJS上使用
这是完全相同的服务响应两个名称,所以我测试完全相同的请求,客户端和服务器代码(DNS名称是可互换的)
经过测试
- Chrome 61.0.3163.100(Windows) - > DELAY
- Chrome 62.0.3202.84(Android) - > DELAY
- Chrome 62.0.3202.84(iOS-Ipad) - >确定!!!
- Firefox - >确定
- 边缘 - >确定
解决方法(在我的情况下)。在我的主机中创建一个代理来响应相同的原始DNS并避免CORS I've been struggling recently with a super-weird problem only happening in Chrome: as my API (NodeJS) is on a different subdomain, I need to use CORS to reach it from my front-end (EmberJS).
It's working pretty well but I'm very frequently (95% of the time) having very very slow OPTIONS queries, delaying any API calls by about 3 seconds.
Most of this time is spent downloading an empty content:
It gets even weirder when I'm trying this on another website we made using a similar architecture, experiencing the exact same problem.
A few other things I tried:
- I've been trying this with Firefox and Safari, and didn't get any delay.
- I've been trying this locally or in production, experimenting the same delay.
- I've been trying this with incognito mode (no extensions), and I have the exact same problem.
We're using on the back-end NodeJS with the CORS package.
Now, I have no idea if the problem is on either Chrome 60, NodeJS, the CORS package or EmberJS + jQuery.
Anyone experienced this too?
解决方案Just as a note: It seems a chrome bug
I reproduced the issue using a server with two DNS names using a service in a unique domain
domain1 --> domain1 (No CORS, no delay) domain2 --> domain1 (CORS, delay)It is exactly the same service responding to two names, so I am testing exactly the same request, client and server code (DNS names are interchangeable)
Tested with
- Chrome 61.0.3163.100 (Windows) -->DELAY
- Chrome 62.0.3202.84 (Android) -->DELAY
- Chrome 62.0.3202.84 (iOS-Ipad) -->OK!!!
- Firefox-->OK
- Edge --> OK
Workaround (in my case). Create a proxy in my host to respond to the same origin DNS and avoid CORS
更多推荐
仅在Chrome中使用超慢速预检选项
发布评论