Pages is not sending any content-type header. As a result, chrome browsers don’t download files.
What are the steps to reproduce the issue?
I have some windows installer files (.msi) I want to host on pages. We can’t create download links because pages does not send any content-type header for these files. In dev mode, wrangler sends “application/octet-stream”, so the browser treats them as binary and downloads them, which is sufficient. But without a content-type header, in live mode Chrome (and Edge) treat these files as text and try to render them.
We can force a download in anchor tags using the download attribute, but that won’t work for links we don’t control such as gmail or outlook. Other than that the only thing we can do is use a link to another server. But the point of using pages was to stop using our server so this is annoying.
May I ask if you’ve considered and tried hosting such file types on an R2 bucket, therefrom connected with custom sub-domain such as downloads.mydomain.com?
Thanks for the response. I have not tried that. I’ll have a look, although to get the file out I would presumably also need a worker (because IIUC you can’t expose R2 directly).
Which is fine, but I’d prefer if I could just run this from pages. These files are not particularly large, they’re on par with a large jpeg. I guess it makes sense that pages would be intended for web files only, it would be helpful if that were noted somewhere.
Other thing which could work for you is, using Transform Rules → Modify Response Header, if you add there for the Field URI path with Operator contains and Value .msi (or with wildcard), Then … “Set Static” HTTP header content-type with Value application/octet-stream, then it might work It should as Transform Rules fire after Pages.