Ask coding questions

← Back to all posts
Web view shows the connection is blocked
h
geekandglitter

I imported a working Django web app into repl.it. It does work in the browser. But in the repl.it web view, it crashes. I've tried four browsers. The ones with the most useful messages were Opera and Firefox.

The Opera message:

1944af39-b599-40cf-a6ba-c1a9f3897dcc.id.replitusercontent.com is blocked
1944af39-b599-40cf-a6ba-c1a9f3897dcc.id.replitusercontent.com refused to connect.
ERR_BLOCKED_BY_RESPONSE

The Firefox message:

Firefox Can’t Open This Page
To protect your security, 1944af39-b599-40cf-a6ba-c1a9f3897dcc.id.replitusercontent.com will not allow Firefox to display the page if another site has embedded it. To see this page, you need to open it in a new window.
Learn more…
Report errors like this to help Mozilla identify and block malicious sites

Firefox "learn more" link:

https://support.mozilla.org/en-US/kb/xframe-neterror-page?as=u&utm_source=inproduct

Voters
CarlosSanchez4
geekandglitter
Comments
hotnewtop
Coder100


change this to

geekandglitter

@Coder100 Yes I already have that. You might remember that helped me solve yesterday's problem, and I appreciate it. But now I have this problem, which is that the server does run in the browser, but it doesn't run in repl.it's web view. If you look at the Firefox link that I found, it says I need to give some kind of permission either through x-frame options or content security policy. Please advise.

Coder100
geekandglitter

@Coder100 Thanks and I will try it but I'm curious about something. If I try to create a new Django web app in repl.it (instead of importing one from github) I don't see any of those CORS settings in the default settings.py. Yet the newly created app works properly in web view. What would explain that?

Coder100

@geekandglitter dark magic

Coder100

i can't be super sure about this, but maybe it's because repl.it has a default option that passes cors automatically that gets override here because it came from github @geekandglitter

geekandglitter

@Coder100 Thanks for sending the link about cors. I followed all the steps to enable cors headers. So now my settings.py is updated, and I have django-cors-headers installed. But I'm getting the same failure anyhow. Is there something more I have to do? Or is there something repl.it admin has to do? Please advise. L

Coder100

interesting, your repl is private @geekandglitter

geekandglitter

@Coder100 Okay I made it public again.

Coder100

hm, yeah probably a bug https://repl.it/bugs
because if you open it in a new tab it works fine @geekandglitter

geekandglitter

@Coder100 I reported this as a bug as you suggested, but have since solved it. However, this solution should be documented for anyone importing a Django web app. I did not need CORS enablement. All I needed was one line in settings.py which appears only when the user creates a new Django web app, but must be added if the user imports an existing web app. Here is the one line of code:
X_FRAME_OPTIONS = '*'
Thank you for all your help. It is appreciated. --Linda

Coder100

Whitelist those apps lol