Using D3 requests (json) over SSL with path url gives mixed content error?

I'm not sure what's going on here, but I thought I would ask the crowd. Basically, I have a JSON fetch data function with D3 that works on my local development server, but when I move on to its production (which is hosted over SSL), I get the following error:

Mixed Content: The page at 'https://myapp.com/' was loaded over HTTPS, 
but requested an insecure XMLHttpRequest endpoint 'http://myapp.com/path/to/mydata/'. 
This request has been blocked; the content must be served over HTTPS.

It works great on simple HTTP. The fact is that I do not specify the scheme or even the endpoint, I just use the absolute path from the web server root as follows:

var url = '/path/to/mydata/'
d3.json(url, function(error, data) {
    // do something with data
}); 

Anyway, can I get this to use SSL? Something similar to "//cdn.com/path/to/asset.js"where the scheme is omitted to allow both SSL and simple HTTP requests depending on the contents of the server.

Update

: Heroku, API, , , , d3.csv jQuery.get.

+4
1

, D3 http . URL:

var url = window.location.protocol + '//path/to/mydata/'
d3.json(url, function(error, data) {
    // do something with data
}); 
0

All Articles