問(wèn)題描述
在 Safari 10.1
上嘗試 CORS 請(qǐng)求
時(shí),在包含查詢參數(shù)(例如 https://example.com/api?v=1),Safari 說(shuō)
When trying a CORS request
on Safari 10.1
, on an URL which includes query parameters (e.g. https://example.com/api?v=1), Safari says
XMLHttpRequest 由于訪問(wèn)控制檢查而無(wú)法加載
XMLHttpRequest cannot load due to access control checks
Chrome/Firefox 運(yùn)行良好.
Chrome/Firefox works fine.
對(duì)于來(lái)自沒(méi)有 ?v=1
的頁(yè)面的請(qǐng)求,Safari 也可以正常工作.
On requests from the page without the ?v=1
, Safari works fine too.
我嘗試從
Access-Control-Allow-Origin: https://example.com
到
Access-Control-Allow-Origin: https://example.com/api?v=1
但這會(huì)破壞 Chrome.
but that breaks Chrome.
有什么建議嗎?
推薦答案
如果有人遇到這個(gè)錯(cuò)誤,它只是發(fā)生在我正在構(gòu)建的應(yīng)用程序中.就我而言,它原來(lái)是 uri 中的尾隨/,導(dǎo)致 301 響應(yīng),出于某種原因,Safari 將其解釋為 500 響應(yīng).
If anyone comes across this error, it just occurred in the application I was building. In my case, it turned out to be a trailing / in the uri, which caused a 301 response, which was for some reason interpreted by Safari as a 500 response.
這篇關(guān)于Safari 10.1:由于訪問(wèn)控制檢查,無(wú)法加載帶有查詢參數(shù)的 XMLHttpRequest的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!