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