問題描述
在 Safari 10.1
上嘗試 CORS 請求
時,在包含查詢參數(例如 https://example.com/api?v=1),Safari 說
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 由于訪問控制檢查而無法加載
XMLHttpRequest cannot load due to access control checks
Chrome/Firefox 運行良好.
Chrome/Firefox works fine.
對于來自沒有 ?v=1
的頁面的請求,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
但這會破壞 Chrome.
but that breaks Chrome.
有什么建議嗎?
推薦答案
如果有人遇到這個錯誤,它只是發生在我正在構建的應用程序中.就我而言,它原來是 uri 中的尾隨/,導致 301 響應,出于某種原因,Safari 將其解釋為 500 響應.
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.
這篇關于Safari 10.1:由于訪問控制檢查,無法加載帶有查詢參數的 XMLHttpRequest的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!