how to setup custom 404 on static site(vanilla, no framework)?

i want to deploy a static site using regular html, css and js, built with vite(so not totally vanilla) but its a multipage static app, that will clearly let the server know if an undefined pageroute is accessed. I want to use a custom 404 page for these cases, I couldn't find instructions to do this. I found this blog post https://www.mickaelvieira.com/blog/2020/01/27/custom-404-page-with-cloudflare-workers.html where he explains that you can kinda hack it with workers. but is this really my only option? Idk, i'm kinda hoping this can just be configured in the project's settings or something.
Mickaël Vieira
Custom 404 page with Cloudflare Workers - Mickaël Vieira - Software...
Hijacking 404 errors and returning a custom 404 page with Cloudflare Workers
2 Replies
Chaika
Chaika3mo ago
You can just upload a 404.html file in output directory https://developers.cloudflare.com/pages/configuration/serving-pages/
You can define a custom page to be displayed when Pages cannot find a requested file by creating a 404.html file. Pages will then attempt to find the closest 404 page. If one is not found in the same directory as the route you are currently requesting, it will continue to look up the directory tree for a matching 404.html file, ending in /404.html. This means that you can define custom 404 paths for situations like /blog/404.html and /404.html, and Pages will automatically render the correct one depending on the situation.
bregue dhue
bregue dhue3mo ago
oooooh yes this is what i'm looking for ty