Skip to content

Commit

Permalink
Applied workaround for MIME issue on windows (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
bexsoft committed Sep 8, 2021
1 parent b13b6db commit 90cadc7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions restapi/configure_console.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ var reHrefIndex = regexp.MustCompile(`(?m)((href|src)="(.\/).*?")`)
// wrapHandlerSinglePageApplication handles a http.FileServer returning a 404 and overrides it with index.html
func wrapHandlerSinglePageApplication(h http.Handler) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// This is used to enforce application/javascript MIME on Windows (https://github.com/golang/go/issues/32350)
if strings.HasSuffix(r.URL.Path, ".js") {
w.Header().Set("Content-Type", "application/javascript")
}

nfrw := &notFoundRedirectRespWr{ResponseWriter: w}
h.ServeHTTP(nfrw, r)
if nfrw.status == 404 || r.URL.String() == "/" {
Expand Down

0 comments on commit 90cadc7

Please sign in to comment.