From df6369b9ad2d00a86b9bb5023a99edcb5ccf8388 Mon Sep 17 00:00:00 2001 From: Niko Reunanen Date: Sun, 3 Aug 2025 12:26:36 +0300 Subject: [PATCH] Serve pb_public as a static asset --- back-end/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/back-end/main.go b/back-end/main.go index 5efaa26..1c5eece 100644 --- a/back-end/main.go +++ b/back-end/main.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "net/http" + "os" "time" "github.com/pocketbase/dbx" @@ -29,10 +30,17 @@ type Project struct { func main() { app := pocketbase.New() + migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{ Automigrate: false, }) + app.OnServe().BindFunc(func(se *core.ServeEvent) error { + se.Router.GET("/{path...}", apis.Static(os.DirFS("pb_public"), false)) + + return se.Next() + }) + app.OnServe().BindFunc(func(e *core.ServeEvent) error { e.Router.GET("/api/hours/{organisation}/{year}/{month}", func(c *core.RequestEvent) error { year := c.Request.PathValue("year")