fix(frontend): исправить embed ассетов и MIME для JS-чанков
This commit is contained in:
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user