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) }) }