小编rro*_*lfo的帖子

当来源为 http 且目标 url 为 https 时,如何在本地网络中发出 POST 请求?

我需要从 POS(销售点)(http)向支付终端(https)发出 POST 请求,它们连接在我的本地网络中。当我向邮递员发出请求时,一切正常,但每当我从 POS 发出请求时,我都会收到错误“POST https://myIPaddress:8443/nexo/ net::ERR_CERT_AUTHORITY_INVALID”

我尝试使用 xhr 对象并使用 jquery 发出请求,但我不断遇到同样的错误

jQuery

const settings = {
      async: true,
      crossDomain: true,
      url: 'https://myIPAdress:8443/nexo/',
      method: "POST",
      data: JSON.stringify({
        data
      })
    };

    $.ajax(settings).done(function (response) {
      console.log(response);
    });
Run Code Online (Sandbox Code Playgroud)

JS/xhr

var data = JSON.stringify({
      data
    });

    var xhr = new XMLHttpRequest();
    xhr.withCredentials = true;

    xhr.addEventListener("readystatechange", function () {
      if (this.readyState === 4) {
        console.log(this.responseText);
      }
    });

    xhr.open("POST", "https://myIPAdress:8443/nexo");

    xhr.send(data);

  });
Run Code Online (Sandbox Code Playgroud)

我希望能够将 POST 请求从 POS 发送到支付终端。

javascript jquery cors adyen

3
推荐指数
1
解决办法
3525
查看次数

标签 统计

adyen ×1

cors ×1

javascript ×1

jquery ×1