Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: static assets use relative paths instead of {{public_url}} #721

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mnutt
Copy link
Collaborator

@mnutt mnutt commented Jan 19, 2023

Note: I'm not expecting this to be immediately merged, just starting a discussion around if this is something we want.

Continuing in my quest to reduce our chances of XSS by removing interpolation from our html templates, this PR removes the need for {{public_url}} to refer to static assets. It also places static assets under assets/ to prevent future namespace collisions between static assets and routes.

One caveat: if you mount your app at /foobar and load http://localhost:8080/foobar, the relative URLs won't work. The index page works around this by auto-redirecting to http://localhost:8080/foobar/ if you load http://localhost:8080/foobar. This seems acceptable to me as a common thing submounted pages might do but I definitely wanted to get feedback on it.

Signed-off-by: Michael Nutt <michael@nuttnet.net>
Signed-off-by: Michael Nutt <michael@nuttnet.net>
Signed-off-by: Michael Nutt <michael@nuttnet.net>
@acalcutt
Copy link
Collaborator

I've seen a lot of PRs relating to public_url, so it leads me to believe it is used by people out there....not sure I'd want to get rid of it.

@mnutt
Copy link
Collaborator Author

mnutt commented Jan 20, 2023

It's retained everywhere we absolutely need it, namely within JSON responses that require absolute URLs. My expectation is that everything in this PR should work for anyone using public_url.

My thought (and feel free to disagree) is I think we can/should eventually get to the entire frontend being static html.

@mnutt mnutt changed the title chore: remove {{public_url}} from static assets in favor of relative paths chore: static assets use relative paths instead of {{public_url}} Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants