Fix loading astro islands

This commit is contained in:
Melon 2025-01-26 01:48:09 +00:00
parent 7760129db2
commit 363439e69b
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
2 changed files with 4 additions and 3 deletions

View File

@ -17,6 +17,7 @@ import (
"github.com/julienschmidt/httprouter" "github.com/julienschmidt/httprouter"
"net/http" "net/http"
"net/url" "net/url"
"path"
"strings" "strings"
) )
@ -98,13 +99,13 @@ func SetupRouter(r *httprouter.Router, config conf.Conf, mailSender *mail.Mail,
r.POST("/logout", hs.RequireAuthentication(hs.logoutPost)) r.POST("/logout", hs.RequireAuthentication(hs.logoutPost))
// theme styles // theme styles
r.GET("/assets/*filepath", func(rw http.ResponseWriter, req *http.Request, params httprouter.Params) { r.GET("/_astro/*filepath", func(rw http.ResponseWriter, req *http.Request, params httprouter.Params) {
name := params.ByName("filepath") name := params.ByName("filepath")
if strings.Contains(name, "..") { if strings.Contains(name, "..") {
http.Error(rw, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) http.Error(rw, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return return
} }
web.RenderWebAsset(rw, req, name) web.RenderWebAsset(rw, req, path.Join("_astro", name))
}) })
// login steps // login steps

View File

@ -17,7 +17,7 @@ import (
) )
var ( var (
//go:embed dist //go:embed all:dist
webDist embed.FS webDist embed.FS
webCombinedDir fs.FS webCombinedDir fs.FS