CORS策略,无访问控制 - 允许 - 孔子' react.js中请求的资源上存在标头
大家好,我知道有关CORS政策的问题很多。但是我仍然没有找到解决方案的解决方案。我正在创建一个通过信用卡具有在线付款功能的页面。 API是银行寄给我的。因此,我无法修改服务器端。我的api是 https://sanalpos.bankname.com.tr/servlet/servlet/servlet/est3dgate/est3dgate 这样。如何在没有服务器端的情况下解决我的CORS策略。您可以在下面看到我的示例代码。
axios.post('https://sanalpos.bankname.com.tr/servlet/est3Dgate', body,
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
"Access-Control-Allow-Methods": "*"
}
})
.then( async response => {
responseFromServer = response.data
console.log("
Hi guys I know there are many questions about CORS Policy. But I still have not found a solution for my case. I'm creating a page which has online payment features by credit-card. And API was send me by Bank. So I cannot modify server-side. My API is https://sanalpos.bankname.com.tr/servlet/est3Dgate like that. How to solve my CORS policy without server-side. You can see my sample code below.
axios.post('https://sanalpos.bankname.com.tr/servlet/est3Dgate', body,
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
"Access-Control-Allow-Methods": "*"
}
})
.then( async response => {
responseFromServer = response.data
console.log("???? ~ file: ThreeDPayment.js ~ line 161 ~ SendCreditCardDetails ~ responseFromServer", responseFromServer)
}).catch( async error => {
console.log("???? ~ file: ThreeDPayment.js ~ line 163 ~ SendCreditCardDetails ~ error", error)
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有服务器端,这是不可能的。 CORS标题必须由服务器在HTTP响应上设置, 由客户在请求上设置。
正如Sarangkkl已经说过的那样,您的服务器代码必须包括
That is not possible without server-side. CORS headers must be set by the server on the HTTP response, not by the client on the request as you do.
As sarangkkl already said, your server code must include something like