Skip to content

Commit

Permalink
Fix JS Content-Type in some Windows environments (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
kermieisinthehouse authored Nov 18, 2021
1 parent ad1db1d commit 5563dbb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ func (s *Server) serve(rw http.ResponseWriter, req *http.Request, fn, suf, enc s
if ctype == "" {
ctype = "application/octet-stream" // Prevent unreliable Content-Type detection on compressed data.
}

// This is used to enforce application/javascript MIME on Windows (https://github.com/golang/go/issues/32350)
if strings.HasSuffix(req.URL.Path, ".js") {
ctype = "application/javascript"
}

rw.Header().Set("Content-Type", ctype)
rw.Header().Set("Etag", info.hash)
Expand Down

0 comments on commit 5563dbb

Please sign in to comment.