CORS策略,无访问控制 - 允许 - 孔子' react.js中请求的资源上存在标头

发布于 2025-01-23 11:55:47 字数 766 浏览 3 评论 0原文

大家好,我知道有关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)
    });

Cors Policy Error

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人海汹涌 2025-01-30 11:55:47

如何在没有服务器端的情况下解决我的CORS策略。

没有服务器端,这是不可能的。 CORS标题必须由服务器在HTTP响应上设置, 由客户在请求上设置。

正如Sarangkkl已经说过的那样,您的服务器代码必须包括

app.use(require("cors")());

How to solve my CORS policy without server-side.

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

app.use(require("cors")());
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文