Force specific Content-Type value for JS (#6)

This commit is contained in:
Lukas Schulte Pelkum 2021-04-29 14:57:08 +02:00
parent 542bb5b17d
commit 5f7df183b4
No known key found for this signature in database
GPG Key ID: 408DA7CA81DB885C
1 changed files with 3 additions and 0 deletions

View File

@ -31,6 +31,9 @@ func Serve() error {
router.GET("/{path:*}", func(ctx *fasthttp.RequestCtx) {
path := string(ctx.Path())
if !strings.HasPrefix(path, "/api") && (strings.Count(path, "/") == 1 || strings.HasPrefix(path, "/assets")) {
if strings.HasPrefix(path, "/assets/js/") {
ctx.SetContentType("text/javascript")
}
frontend(ctx)
return
}