diff --git a/backend/cmd/main.go b/backend/cmd/main.go index 21d9197..ba53593 100644 --- a/backend/cmd/main.go +++ b/backend/cmd/main.go @@ -262,6 +262,13 @@ func setupEmbeddedFrontend(r *gin.Engine) { } r.GET("/assets/*filepath", func(c *gin.Context) { + filepath := strings.TrimPrefix(c.Request.URL.Path, "/assets/") + file, err := distFS.Open(filepath) + if err != nil { + c.JSON(404, gin.H{"error": "asset not found"}) + return + } + file.Close() c.Header("Cache-Control", "public, max-age=31536000, immutable") c.FileFromFS(c.Request.URL.Path, http.FS(distFS)) }) diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 2602ef7..fa2796c 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -13,6 +13,12 @@ const router = createRouter({ }, }) +router.onError((error) => { + if (error.message.includes('Failed to fetch dynamically imported module')) { + window.location.reload() + } +}) + createRouterGuard(router) export default router