Embedding Streamlit app to a web app

Helloo guys,

I am trying to embed my streamlit app to my web app. but it needs to be https. what i did is have an aws cloudfront with http port 8501 protocol where the origin domain is the ec2 instance where my streamlit is.

now it works fine but here is an error when i inspect element it.

This error only appears when i embed it to the web app.

My streamlit app is hosted in an ec2 instance with nginx port 80 where it is under cloudfront with HTTP only at port 80.

VM244:1 Uncaught (in promise) SyntaxError: Unexpected non-whitespace character after JSON at position 3 (line 1 column 4)
    at JSON.parse (<anonymous>)
    at MetricsManager.getAnonymousId (index.Phesr84n.js:798:13392)
    at MetricsManager.initialize (index.Phesr84n.js:798:10521)
    at App.handleOneTimeInitialization (index.Phesr84n.js:798:34546)
    at App.handleNewSession (index.Phesr84n.js:798:33465)
    at Object.newSession (index.Phesr84n.js:798:28859)
    at ot (index.Phesr84n.js:798:28763)
    at App.handleMessage [as onMessage] (index.Phesr84n.js:798:28825)
    at WebsocketConnection.handleMessage (index.Phesr84n.js:798:3075)

for some reasons i cant create a domain thats why im using cloudfront.

any ideas how can i fix this? any help would be appreciated!

anyways, i fixed it by disabling the usage statistics in streamlit.

gatherUsageStats = false

but this might be a cloudfront configuration issue as well i guess?

1 Like