简体   繁体   中英

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.

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'. This request has been blocked; the content must be served over 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 .

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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