POST axios请求被fluidpay api阻止



我试图发送一个post请求到这个端点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不应该被所有域访问吗?

EDIT

看起来CORS是禁用的服务器端。如果你不能控制服务器,你就不能用浏览器做很多事情。解决这个问题的唯一方法是使用自己拥有的API来代理请求。

点击这里阅读更多