cloudflare / templates

A collection of starter templates and examples for Cloudflare Workers and Pages
https://cloudflareworkers.com
MIT License
999 stars 632 forks source link

404 page doesn't render in HTML but plain text #62

Closed roshanjonah closed 2 years ago

roshanjonah commented 2 years ago

Hi there,

I think this is a bug in Cloudflare Workers.

We are using Hugo and Cloudflare workers to push our static site, and Github does the automatic build and push.

% curl -svo /dev/null https://jonahnz.com/404.html

That seems to have content type but not this random 404 address: % curl -svo /dev/null https://jonahnz.com/non-existing-URL

For some odd reason, the HTML is not rendering so if there is a non-existing URL like https://jonahnz.com/randskdfskuh - you can see it displays just raw HTML rather than outputting this page https://jonahnz.com/404.html

lukeed commented 2 years ago

This behavior doesn’t come for free with Workers but it does with Pages. Sounds like you should be using that for this project — you can still deploy a sibling Worker alongside your Pages project if you have any dynamic endpoints