我正在嘗試向此端點發送發布請求https://sandbox.fluidpay.com/api/token-auth并且我收到此錯誤:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://sandbox.fluidpay.com/api/token-auth. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 405
當我從 Postman 發送請求時,它起作用了。但是當我嘗試使用 axios 發送它時,出現了上述錯誤。
這就是我使用 axios 發出請求的方式:
const request = await axios({method: "post", url: "https://sandbox.fluidpay.com/api/token-auth", data: {username: username, password: password}, withCredentials: false});
公共 API 不應該可供所有域訪問嗎?
uj5u.com熱心網友回復:
編輯
看起來 CORS 在服務器端被禁用。如果你不控制服務器,你就不能用瀏覽器做很多事情。解決問題的唯一方法是使用自己擁有的 API 來代理請求。
在這里閱讀更多
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/534468.html
