Repository navigation
web: fix frontend assets behind reverse-proxy subpaths - #8384
Conversation
unknwon
left a comment
There was a problem hiding this comment.
Thanks for the PR!
However it seems too many related changes bundled together. If you wanna land this PR, I think only the changes in cmd/gogs/internal/web/webapp_prod.go is needed?
duytbp
left a comment
There was a problem hiding this comment.
Thanks for taking a look. I updated the Caddy heading and reorganized the tests.
I tested limiting the fix to webapp_prod.go, but that only fixes the backend side. The complete flow has three parts:
vite.config.tsmakes URLs inside the generated CSS and JavaScript relative. Without this, fonts and workers still request/assets/...and bypass/gogs/*.web.gogives the main JavaScript and CSS entrypoints a stable/gogs/assets/...URL. Without this, opening a deeper page directly can resolve them under the wrong path.webapp_prod.goserves those requests after the proxy strips/gogs, leaving Gogs with/assets/....
Each change handles a different stage of the same asset request, so removing any one leaves part of the frontend broken.
I am not sure I follow, aren't |
|
Those replacements only run against Without |
Ok that makes sense. Now if we use |
|
Yes, I just verified that the build only uses |
c4359ae to
3d8d6d2
Compare
Describe the pull request
Fixes #8385.
This change makes production frontend assets work behind a prefix-stripping reverse proxy and updates the Caddy subpath example.
Checklist
Test plan
/gogsusing the Caddy configuration documented in this PR./gogs/assets/.moon run gogs:test.go test -tags=prod ./cmd/gogs/internal/web.moon run web:lintandmoon run web:build.