Home > Back-end >  How to access a website deployed on heroku from an iframe?
How to access a website deployed on heroku from an iframe?

Time:07-19

I created a website in Django that I deployed on heroku. It contains the following line in its settings.py file:

ALLOWED_HOSTS = ['*']

This means that it allows connection with any domain name. But when I try to access a site from an iframe on an html page from my localhost, I get the following error when loading my webpage:

gkwhelps.herokuapp.com refused the connection.

here is the code of my iframe:

<Iframe src="https://gkwhelps.herokuapp.com"
                            width="450px"
                            height="450px"
                            />

I don't know why this happens because I authorized access to all hosts before deploying on heroku, I don't know if heroku has a policy about this which conditions the access to other hosts or the error comes from elsewhere. Thanks !

CodePudding user response:

If you look at the headers of your Heroku app, you will see the following:

X-Frame-Options: DENY

This means that Heroku refuses to accept iframe connections - hence the error you have received.

  • Related