FRONTEND_PATH is not applied for assets URLs
Describe the bug When using frontend_path parameter (in my case used as env variable), when referencing assets in /assets folder, frontend_path is not added, throwing 404 errors for those resources
To Reproduce Execute reflex populating FRONTEND_PATH env variable. Add some assets in /assets folder and reference them as stated in documents (prefixing them with slash '/').
Expected behavior Assets path should add FRONTEND_PATH to the referenced resources.
Screenshots
Specifics (please complete the following information):
- Python Version:3.12
- Reflex Version: 0.6.5
- OS: Linux
- Browser (Optional):
Additional context Add any other context about the problem here.
In order to give more clues, this doesn't work in two parts:
- favicon (located in /assets)
- Resources referenced from css that are located in /assets too, like:
@font-face {
font-family: inetum;
font-weight: bold;
src: url("/fonts/Poppins-Bold.ttf") format("truetype");
}
In font case, unless I am prefixing the url with FRONTEND_PATH, it won't work.
@juangon can you try with rx.asset and this PR https://github.com/reflex-dev/reflex/pull/4460 ?
Thanks @benedikt-bartscher , but how can I use rx.asset inside a CSS file?
Thanks @benedikt-bartscher , but how can I use rx.asset inside a CSS file?
You can't, maybe there is a way to set the frontend root in package.json and let react adjust all those paths instead?
My pr is just a draft for rx.asset support, not a full fix for this
We do have some path rewriting here https://github.com/reflex-dev/reflex/blob/a320d062fb739235642c95fc4907f7d5f9531e44/reflex/.templates/web/jsconfig.json#L5-L6, but i think this applies only to js files, not to css.
Assets path should add FRONTEND_PATH to the referenced resources.
I don't know if this is generally achievable while still making it possible to access files from the root of the host ("above" where the reflex app is served)
From my point of view, as I would like to "detach" the needed configuration from testing (ie., all localhost and root path) to production (proxy and URL that uses paths to serve different services). I would like having DEPLOY_URL variable as the path that reflex adds to every relative path within the application. I think FRONTEND_PATH and DEPLOY_URL sounds a bit duplicate for the same stuff maybe.