Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTPS iframe inside a HTTPS page not working

How can we use github pages embedded in an iframe correctly?

I've hosted a website in firebase and it is using a custom domain over https, for example, https://www.example.com.

This website uses react and other things, but for one route (the landing page one) I would like to use a static page hosted on github, for example https://example.github.io/page. So, to achieve this I've created an iframe inside the route https://www.example.com/page.

The problem is I've been receiving the following error:

Mixed Content: The page at 'https://www.example.com/page' was loaded over HTTPS, but requested an insecure resource 'http://example.github.io/page/'. This request has been blocked; the content must be served over HTTPS.

The strange thing is the iframe looks correctly:

<iframe title="Page" src="https://example.github.io/page">unwanted text</iframe>

It is already using https, but looks like this is being ignored. I already tried to use this meta <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">, close the iframe with </iframe> and add an unwanted text inside the iframe.

Can we solve this?

like image 913
GarouDan Avatar asked Jan 07 '18 14:01

GarouDan


People also ask

How do I fix refused connection in iframe?

You cannot fix this from Power Apps Portal side. Most probably web site that you try to embed as an iframe doesn't allow to be embedded. You need to update X-Frame-Options on the website that you are trying to embed to allow your Power Apps Portal (if you have control over that website).

Can you embed HTTPS?

Only secure web sites can be embedded. Make sure the URL of the web site begins with HTTPS. Not all websites allow their pages to be embedded, so you may not be able to embed them, even when they are secure and use iframe-based embed code. If you have problems, check with the website to see if they allow embedding.


1 Answers

If you carefully examine your HTML code and the error message, you'll notice a slight difference in URLs besides the protocol part:

  • https://example.github.io/page - in the iframe src tag
  • http://example.github.io/page/ - in the error message

The reason could be that the URL https://example.github.io/page returns a redirect to the "canonical" version with the trailing slash (/page/), but a redirect URL must be a full URL, and the server for some reason isn't including the actual protocol in the redirect URL, always using http:// instead. That could be due to configuration or coding at the server side (see also github issue #289).

As a workaround, use a URL that doesn't trigger the canonicalization redirect, i.e. https://example.github.io/page/.

like image 57
rustyx Avatar answered Sep 17 '22 15:09

rustyx