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

Redo the buildchain with vite #718

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Change /pub to /assets
danopia committed Aug 20, 2024
commit 6a3b5072dd291b133bc15db3a44285d659d557f7
8 changes: 4 additions & 4 deletions internal/webserver/webserver.go
Original file line number Diff line number Diff line change
@@ -97,9 +97,9 @@ func HandleHTTP(port string) {
r.PathPrefix("/rollback/").HandlerFunc(spaHandler)

// Static content
// react is told that it'll be mounted at /pub
staticServer := http.StripPrefix("/pub", http.FileServer(http.Dir("./web/react-frontend")))
r.PathPrefix("/pub/static/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// react is told that it'll be mounted at /assets
staticServer := http.StripPrefix("/assets", http.FileServer(http.Dir("./web/react-frontend")))
r.PathPrefix("/assets/static/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// All files inside static are keyed by hash
w.Header().Add("Cache-Control", "public, max-age=604800, immutable")
// Also loosen caching on 404 to prevent mixed-fleet poisoning
@@ -108,7 +108,7 @@ func HandleHTTP(port string) {
ErrorCaching: "public, no-cache, max-age=60",
}, r)
})
r.PathPrefix("/pub/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r.PathPrefix("/assets/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// icons etc aren't hashed
w.Header().Add("Cache-Control", "public, max-age=300")
staticServer.ServeHTTP(w, r)