如何在使用 https 的网站中通过 http 发送 post 请求?
how to send a post request through http in website that uses https?
我正在创建一个 chrome 扩展,它需要通过普通 http 向服务器发送 post 请求,但这会导致混合内容错误,并且当我在一个使用 Https 的网站。
错误信息:
混合内容:'https://www.google.com/' 的页面是通过 HTTPS 加载的,但请求了不安全的 XMLHttpRequest 端点 'http://example.se:8080/v1/check'。此请求已被阻止;内容必须通过 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);
});
不推荐使用mix-content,您应该使用HTTPS。
但如果您出于 开发目的 想要绕过它,您可以在站点设置。
中允许它
参考这个问题
How to get Chrome to allow mixed content?
我正在创建一个 chrome 扩展,它需要通过普通 http 向服务器发送 post 请求,但这会导致混合内容错误,并且当我在一个使用 Https 的网站。
错误信息:
混合内容:'https://www.google.com/' 的页面是通过 HTTPS 加载的,但请求了不安全的 XMLHttpRequest 端点 'http://example.se:8080/v1/check'。此请求已被阻止;内容必须通过 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);
});
不推荐使用mix-content,您应该使用HTTPS。
但如果您出于 开发目的 想要绕过它,您可以在站点设置。
中允许它参考这个问题 How to get Chrome to allow mixed content?