javascripthttpsmixed-content

Image Resource Loaded via JS Gets Automatically Upgraded to HTTPS


When loading an image from a secure server via JS with the following code:

var preloadImage = new Image(); preloadImage.src = 'http://some/resource.png';

The request gets automatically upgraded to https. Presumably it's a well intentioned feature to stop mixed content. However the server I'm pointing to can only do http. I've been browsing the methods and properties available on Image to no avail. I mean ideally yes, the image would be https, but it's just a temp server spun up on AWS so if we can avoid it for now, that'd be much easier.

Does anyone have a workaround to stop JS automatically upgrading the request?


Solution

  • It turns out a recent update to most browsers has stopped mixed content all together. Before it used to throw a warning, now it's just not possible. We got around it with some nginx reverse proxy magic where we passed the IP in the URL like https://normal-domain/preview/IPADDESSS and it's working now.