From a4157d13634177578cddc3a41fe047cbf1f1a4d3 Mon Sep 17 00:00:00 2001 From: Crimson Date: Sat, 9 May 2026 13:28:37 +0500 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D1=82=D1=8C=20embed=20=D0=B0=D1=81=D1=81=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=B2=20=D0=B8=20MIME=20=D0=B4=D0=BB=D1=8F=20JS-?= =?UTF-8?q?=D1=87=D0=B0=D0=BD=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/frontend/embed.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/frontend/embed.go b/apps/frontend/embed.go index d93c3da..c6a2471 100644 --- a/apps/frontend/embed.go +++ b/apps/frontend/embed.go @@ -5,12 +5,13 @@ import ( "fmt" "github.com/gin-gonic/gin" "io/fs" + "mime" "net/http" "path" "strings" ) -//go:embed dist/* +//go:embed all:dist var staticFiles embed.FS func InitFrontend(router *gin.Engine, relativePath string) { @@ -45,7 +46,11 @@ func InitFrontend(router *gin.Engine, relativePath string) { c.String(http.StatusNotFound, "404") return } - c.Data(http.StatusOK, http.DetectContentType(fileContent), fileContent) + contentType := mime.TypeByExtension(path.Ext(filePath)) + if contentType == "" { + contentType = http.DetectContentType(fileContent) + } + c.Data(http.StatusOK, contentType, fileContent) }) }