Open drnguyenn opened 11 months ago
@andfanilo Hi. I've made a small fix to the problem described in #133. Can you please take a look?
@drnguyenn This solves my problem (I deploy to google cloud run with a load balancer that routes to a subpath)! Thank you so much!
@supern8ent That's great. I'm glad that it can help you.
Oh my, I missed the first notification, I'm so sorry! Let me put that in my todo list for next week, especially since another person has validated it works :)
@andfanilo Thank you so much. I hope it's worth your time.
Close #133
Summary
Fix an issue of the background image does not show up when Streamlit server base URL path is specified (via
config.toml
file,--server.baseUrlPath
when running, or environment variableSTREAMLIT_SERVER_BASE_URL_PATH
). Version: 0.9.3Description
The
background_image_url
obtained fromst_image.image_to_url
has the format:/media/xxxxxx.png
. If we specify theserver.baseUrlPath
like, for example,foo
:And when the URL is constructed at the frontend side with the origin:
A single slash
"/"
is missing between the origin and the base path, so the image can not be loaded.This PR handles the
server.baseUrlPath
a little bit before appending it to the head of the image URL returned fromst_image.image_to_url
. I strip all the extra leading and trailing slashes if there are any and then add a single one to the beginning so that the frontend side can construct the correct path.How Has This Been Tested?
I've tested locally in Docker environment and the original example
app.py
inREADME.md
: Dockerfile:Build a test image:
Run the container:
You can also try different strange values for
server.baseUrlPath
like///foo/bar//
, etc.Open browser and confirm that the background image is always displayed correctly.