1
0
Fork 0

devtools/hackdoc: serve JS with correct mimetype

This allows us to serve rich content from hackdoc, eg. hbj11's
webflaser.

Change-Id: Ife83888d864db0b2eddf3a50b0129be0172aad8a
master
q3k 2021-03-23 15:50:19 +00:00
parent a025e63263
commit 56c262f2b6
2 changed files with 10 additions and 3 deletions

View File

@ -151,7 +151,14 @@ func (r *request) handleFile(path string, cfg *config.Config) {
}
// Just serve the file.
mime := mimetype.Detect(data)
r.w.Header().Set("Content-Type", mime.String())
var mime string
if strings.HasSuffix(path, ".js") {
// Force .js to always be the correct MIME type.
mime = "text/javascript"
} else {
// Otherwise, use magic to detect type.
mime = mimetype.Detect(data).String()
}
r.w.Header().Set("Content-Type", mime)
r.w.Write(data)
}

View File

@ -3,7 +3,7 @@ local kube = import "../../kube/kube.libsonnet";
{
cfg:: {
image: "registry.k0.hswaw.net/q3k/hackdoc:315532800-a415ced850425a195f96b331f57cd78f15e622d9",
image: "registry.k0.hswaw.net/q3k/hackdoc:315532800-f4d02581f60b18a8635d026079ed67039cdc45e6",
publicFQDN: error "public FQDN must be set",
},