简体   繁体   English

如何在使用https的网站中通过http发送post请求?

[英]how to send a post request through http in website that uses https?

I am creating a chrome extension that need to send post request to a server over normal http but this causes a mixed content error and browser don't process the request when I am in a website that user Https.我正在创建一个 chrome 扩展,它需要通过普通的 http 向服务器发送发布请求,但这会导致混合内容错误,并且当我在用户 Https 的网站中时,浏览器不处理请求。

error message:错误信息:

Mixed Content: The page at 'https://www.google.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://example.se:8080/v1/check'.混合内容:“https://www.google.com/”上的页面已通过 HTTPS 加载,但请求了不安全的 XMLHttpRequest 端点“http://example.se:8080/v1/check”。 This request has been blocked;此请求已被阻止; the content must be served over HTTPS.内容必须通过 HTTPS 提供。

    var settings = {
  "url": "http://example.se:8080/v1/check",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "postman-token": "e7705111-e7d7-0284-e4cd-56115243e076",
    "Content-Type": "application/json"
  },
  "data": JSON.stringify({"langCode":"pt-rr","text":"Por favor, leia as regrs. Meu nom é Nicolas. bowré o qunto maor pabn dks do."}),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});

It is not recommendable to use mix-content , You should use HTTPS .不推荐使用mix-content ,你应该使用HTTPS

But if you want to bypass it for Development Purpose , You can allow it in site settings .但是如果您想出于开发目的绕过它,您可以在站点设置中允许它。

Refer this question How to get Chrome to allow mixed content?请参阅此问题如何让 Chrome 允许混合内容?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM