Fetch URL?

My app is hosted on render and I need a way to fetch the URL to see if a subdomain exists to trigger conditions

I was able to get it working fine locally with this:

from streamlit_javascript import st_javascript
st_javascript(“await fetch(‘’).then(r => window.parent.location.href)”)

However, it rarely if ever works when deployed to the cloud. I loop rerun until the URL is fetched which means infinite loop or 30+ reruns if it does end up getting it.

Surely there is an easier way of tackling this??
streamlit==1.35.0

Edit: I stumbled upon the fix. Posting here for anyone else who runs into this:

I had to switch to a different package built on top of streamlit-javascript that blocks streamlit until the JS is fully executed. Here you go:

from streamlit_js import st_js_blocking
st_js_blocking(code=“return window.parent.location.href;”)

Big props to @toolittlecakes for making this component available, ty!!!