Fix 404s: serve UI templates/static from configurable ui-root, not CWD
The web UI 404'd in production because templates/static were loaded
via relative paths ("internal/ui/templates", "internal/ui/static"),
which only resolved when running from the repo checkout. systemd sets
WorkingDirectory=/var/lib/wireguard-ui-multi, so those paths never
existed there.
Add a -ui-root flag (default /usr/local/share/wireguard-ui-multi/ui),
have install.sh copy internal/ui there, and resolve templates/static
paths through it instead of hardcoded relative strings.
Also add release-binary fast path to bootstrap.sh (falls back to
source build with CGO_ENABLED=0/-trimpath if no release exists yet),
and document real hardware/build-RAM requirements in the README.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
b2b6b82f58
commit
41894e67c6
@@ -4,8 +4,6 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const templatesDir = "internal/ui/templates"
|
||||
|
||||
// hasSession reports whether the request carries a valid, non-expired session cookie.
|
||||
func (a *API) hasSession(r *http.Request) bool {
|
||||
c, err := r.Cookie(sessionCookieName)
|
||||
@@ -21,7 +19,7 @@ func (a *API) handleDashboard(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/login", http.StatusFound)
|
||||
return
|
||||
}
|
||||
http.ServeFile(w, r, templatesDir+"/dashboard.html")
|
||||
http.ServeFile(w, r, a.templatesDir()+"/dashboard.html")
|
||||
}
|
||||
|
||||
func (a *API) handleLoginPage(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -29,7 +27,7 @@ func (a *API) handleLoginPage(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/", http.StatusFound)
|
||||
return
|
||||
}
|
||||
http.ServeFile(w, r, templatesDir+"/login.html")
|
||||
http.ServeFile(w, r, a.templatesDir()+"/login.html")
|
||||
}
|
||||
|
||||
func (a *API) handleServerPage(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -37,5 +35,5 @@ func (a *API) handleServerPage(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/login", http.StatusFound)
|
||||
return
|
||||
}
|
||||
http.ServeFile(w, r, templatesDir+"/server.html")
|
||||
http.ServeFile(w, r, a.templatesDir()+"/server.html")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user