Paulo
Paulo

Reputation: 1498

How to requesting javascript file of an HTTP server from HTTPS server

Well, I have an application that runs over HTTPS and there are requests to load some javascript files from a server that runs over HTTP (there is no HTTPS option for these javascript files), and, obviously, I'm getting this error:

Mixed Content: The page at 'https://myapplication.url.com/ was loaded over HTTPS, but requested an insecure script 'http://another.application/file.js'. This request has been blocked; the content must be served over HTTPS.

A solution I found at SO was: instead of request for http://another.application/file.js, someone suggest removing http:, leaving //another.application/file.js. It doesn't work. It tries to request from HTTPS and there is no HTTPS option for the file.js.

I've just read some related topics here:

Request to a json resource from an http page to an https server

Downloading files from an http server in python

HTTP Request originated from HTTP Server

But, unfortunately, none of them gave me a clue. Has someone already got this error and how does one solve that?

I don't know if it matters, but I'm using tomcat6, java7 and the problem occurs when I try to include the file in index.html:

That's the code I use:

script type="text/javascript" src="http://another.application/file.js"

Upvotes: 0

Views: 1658

Answers (1)

Gavriel
Gavriel

Reputation: 19237

There's no client side solution I know of.

You can set up a proxy on your server so that file can be requested through your server (https). But then maybe it's easier to just copy that file to your server and serve it from there (if it's static).

Or if you use a CDN, then you can set it up to include those files from the other (http-only) server, but such that the CDN serves them via https.

Upvotes: 1

Related Questions