reflex icon indicating copy to clipboard operation
reflex copied to clipboard

Images not found if the app is not depolyed on the root domain, but on a subpath

Open alq-eium opened this issue 3 months ago β€’ 2 comments

I have several images on my /assests folder (image1.png, image2.png...), therefore I insert images with this command rx.image(src="/image1.png"). My app is meant to be deployed on http://myproject.com/app instead of http://myproject.com/. I have configured frontend_path="/app" on my rxconfig.py file. However, when I load the page on my web browser the images are not found because they are searched on /image1.png instead /app/image1.png.

How should I proceed in this case? Should I use rx.image(src="/app/image1.png") instead of rx.image(src="/image1.png") or is there a better option?

Best regards, Alejandro

alq-eium avatar Oct 21 '25 12:10 alq-eium

i think either absolute paths with rx.image(src=f"{config.frontend_path}/image1.png") is probably your best bet. the framework might handle this some day, but i'm not aware of any trivial framework-level fix that would just allow this to transparently work.

you could also use relative paths in your src, but then if that component gets used in routes with different levels of subdirs, those relative links will break too. for something that sounds so simple, it's not a straightforward problem to generally solve.

masenf avatar Oct 31 '25 17:10 masenf

Thank you @masenf!! I have chosen your solution, it's simple and effective.

alq-eium avatar Nov 02 '25 21:11 alq-eium