Download an HTTPS image URL that can redirect HTTP

I am using a specific API that has an agreement with the image url:

https://us.battle.net/static-render/us/illidan/249/96749817-avatar.jpg?alt=wow/static/images/2d/avatar/6-0.jpg

(How this URL received is not relevant to the question, so I will not explain). But basically, the server will be redirected to an alternative thumbnail if the exact image is not found. The problem is that the server redirects to http when redirecting, even if the original call is made through https . My page using these URLs uses https , so I get warnings.

Is there an easy way in javascript / html that I can use https urls even if the server is redirected to http ? Please visit the above URL to understand what I mean. Perhaps one option is to download via javascript and intercept the redirect, change the protocol to https, etc., but it looks a bit complicated.

As a test code, just an html page with the code below is enough (you need to download it via https to see the problem):

 <html> <head>...</head> <body> <img src='https://us.battle.net/static-render/us/illidan/249/96749817-avatar.jpg?alt=wow/static/images/2d/avatar/6-0.jpg'> </body> </html> 
+6
source share
1 answer

With javascript and HTML, this will not work because Google Chrome blocks anything with http addresses on secure sites.
If the alternate image is on your server, you can paste it using https.
If not, you need a PHP curl script that parses the http image and makes it available at the https URL.

+2
source

Source: https://habr.com/ru/post/976423/


All Articles