Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page loaded over HTTPS but requested an insecure XMLHttpRequest endpoint

I have a page with some D3 javascript on. This page sits within a HTTPS website, but the certificate is self-signed.

When I load the page, my D3 visualisations do not show, and I get the error:

Mixed Content: The page at 'https://integration.jsite.com/data/vis' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://integration.jsite.com/data/rdata.csv'. This request has been blocked; the content must be served over HTTPS.

I did some research and all I found what the JavaScript will make the call with the same protocol that the page was loaded. So if page was loaded via https then the rdata.csv should also have been requested via https, instead it is requested as http.

Is this because the certificate is self-signed on the server? What I can do to fix this, other than installing a real SSL certificate?

like image 830
J86 Avatar asked May 23 '16 09:05

J86


5 Answers

What I can do to fix this (other than installing a real SSL certificate).

You can't.

On an https webpage you can only make AJAX request to https webpage (With a certificate trusted by the browser, if you use a self-signed one, it will not work for your visitors)

like image 161
Tom Avatar answered Nov 11 '22 06:11

Tom


I had the same issue for my angular project, then I make it work in Chrome by changing the setting. Go to Chrome setting -->site setting -->Insecure content --> click add button of allow, then add your domain name [*.]XXXX.biz

Now problem will be solved.

like image 32
user2791178 Avatar answered Nov 11 '22 06:11

user2791178


Steps to Allow Insecure Content in Chrome

To allow insecure content on individual sites within Chrome, click on the lock icon in the URL bar, then click 'Site settings'.

enter image description here

There you will see a list of various permissions the page has. Choose 'Allow' next to 'Insecure content'.

enter image description here

Now your HTTPS site can access HTTP endpoint

like image 21
Smack Alpha Avatar answered Nov 11 '22 06:11

Smack Alpha


I solved the problem adding a slash at the end of the requesting url

This way: '/data/180/' instead of: '/data/180'

like image 9
Flavio Lopes Avatar answered Nov 11 '22 08:11

Flavio Lopes


You will be able to solve the error by adding this code to your html file:

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />

If any solutions don't work, try this solution.

like image 9
Kai - Kazuya Ito Avatar answered Nov 11 '22 06:11

Kai - Kazuya Ito