Use proper content-type for downloads to avoid Chrome insecure download block

This commit is contained in:
James 2026-02-12 17:53:51 -05:00
parent a1d156bbd5
commit 9d6ad09b53
1 changed files with 5 additions and 1 deletions

View File

@ -299,7 +299,11 @@ func servePDF(w http.ResponseWriter, r *http.Request) {
return
}
defer f.Close()
w.Header().Set("Content-Type", "application/octet-stream")
if ext == ".pdf" || ext == "" {
w.Header().Set("Content-Type", "application/pdf")
} else {
w.Header().Set("Content-Type", "text/plain")
}
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, filename))
w.Header().Set("Content-Length", fmt.Sprintf("%d", fi.Size()))
io.Copy(w, f)