From 9d6ad09b53a7eb2789ac8a4eb4f0cbfe2f19820c Mon Sep 17 00:00:00 2001 From: James Date: Thu, 12 Feb 2026 17:53:51 -0500 Subject: [PATCH] Use proper content-type for downloads to avoid Chrome insecure download block --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 001cacf..4f3cf2d 100644 --- a/main.go +++ b/main.go @@ -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)