Super slow preflight OPTIONS in Chrome only

前端 未结 3 739
無奈伤痛
無奈伤痛 2021-02-04 00:10

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-

3条回答
  •  囚心锁ツ
    2021-02-04 00:35

    I found the solution for my case and I will share it here.

    I am on Windows, using Chrome version 70, runing a AngularJS front-end with a nodeJS backend with restify on the same server. I am using fiddler to monitor the requests, and OPTIONS request can take 1 second some times, while some times just < 5 ms. Stop using Filler bring that maximum time down to 300 ms, but still considered long. And this delay happens in Chrome, but not in Firefox. I did not test other browsers.

    My case might be different from the question, as I looked the Chrome network timeline, when Fiddler is present, there is a 1s waiting(TTFB) delay. And when Fiddler is not on, there is a 300 ms gap between DNA lookup and initial connection.

    I finally found this AJAX query weird delay between DNS lookup and initial connection on Chrome but not FF, what is it?

    Just change back-end connection URL from localhost to 127.0.0.1 and It solved my problem perfectly.

提交回复
热议问题