仅在Chrome中使用超慢速预检选项 [英] Super slow preflight OPTIONS in Chrome only

查看:232
本文介绍了仅在Chrome中使用超慢速预检选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在苦苦挣扎,只在Chrome中出现了一个超级奇怪的问题:由于我的API(NodeJS)位于不同的子域,所以我需要使用CORS从我的前端(EmberJS)访问它。 / p>

它工作得很好,但我经常(95%的时间)拥有非常慢的OPTIONS查询,将任何API调用延迟了大约3秒。





大部分时间都花在下载一个空的内容:



它变得更加怪异当我在另一个网站上尝试使用类似的架构时,遇到了完全相同的问题。



d:


  • 我一直在用Firefox和Safari试试这个功能,并没有得到任何延迟。 b
  • 我一直试图在本地或在生产中尝试相同的延迟。
  • 我一直在使用隐身模式(无扩展名)尝试此操作,并且我确切地同样的问题。



我们在后端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

https://domain1.com  --> https://domain1.com (No CORS, no delay)
https://domain2.com  --> https://domain1.com (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中使用超慢速预检选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆