仅在Chrome中使用超慢速预检选项

编程入门 行业动态 更新时间:2024-10-26 20:35:53
本文介绍了仅在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

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中使用超慢速预检选项

本文发布于:2023-10-09 16:46:06,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:慢速   选项   Chrome

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!