以下問題。我想通過ajax具有重定向調用一個網站,但請求失敗原因是「沒有‘訪問控制允許來源’標頭」錯誤:獲取重定向URL,儘管沒有「Access-Control-Allow-Origin」標頭
XMLHttpRequest cannot load https://somesite.com. Redirect from 'https://somesite.com' to 'https://someothersite.com/index.php' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://anysite.com' is therefore not allowed access.
我要的是顯示在錯誤響應(並且是可變的)中的重定向URL。我似乎無法訪問它,但因爲它顯示在錯誤響應中,我認爲它應該可以訪問以某種方式。
$.ajax({
type: "POST",
url: "https://somesite.com"
});
感謝您的任何幫助。
請參考這個鏈接已經解釋好'(https://stackoverflow.com/questions/28547288/no-access-control-allow-origin-header-is-present-on-the-requested-resource-err )' –
@Legman請重新閱讀這個問題。 –
此錯誤消息看起來像您的網絡開發工具會拋出的錯誤消息,而不是您可以從Web API中的任何位置訪問的錯誤消息。 (即我不認爲你可以...) – Kaiido