I faced this error in a static site deployment to Cloudflare Pages (aka Workers and Pages).
What ultimately worked was to simply add a 404.html file in the site's root. From the Pages docs:
If your project does not include a top-level 404.html file, Pages assumes that you are deploying a single-page application. This includes frameworks like React, Vue, and Angular. Pages' default single-page application behavior matches all incoming paths to the root (/), allowing you to capture URLs like /about or /help and respond to them from within your SPA.