fix(frontend): исправить embed ассетов и MIME для JS-чанков

This commit is contained in:
2026-05-09 13:28:37 +05:00
parent 2e8e88bccc
commit a4157d1363
+7 -2
View File
@@ -5,12 +5,13 @@ import (
"fmt" "fmt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"io/fs" "io/fs"
"mime"
"net/http" "net/http"
"path" "path"
"strings" "strings"
) )
//go:embed dist/* //go:embed all:dist
var staticFiles embed.FS var staticFiles embed.FS
func InitFrontend(router *gin.Engine, relativePath string) { func InitFrontend(router *gin.Engine, relativePath string) {
@@ -45,7 +46,11 @@ func InitFrontend(router *gin.Engine, relativePath string) {
c.String(http.StatusNotFound, "404") c.String(http.StatusNotFound, "404")
return 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)
}) })
} }