Repository navigation
Support a custom SPA fallback file in Workers Static Assets #16672
Barbapapazes
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello 👋,
Currently, Workers Static Assets supports SPA routing through the
not_found_handlingoption:{ "assets": { "directory": "./dist", "not_found_handling": "single-page-application" } }However, this behavior is hardcoded to serve
/index.htmlfor unmatched routes.It would be useful to allow developers to configure the fallback HTML file instead of always using
index.html.Some frameworks, such as Nuxt, generate separate HTML files for prerendered routes and client-side navigation.
For example, when running
nuxt generate, Nuxt produces:index.html: The prerendered homepage.200.html: A generic SPA fallback used to render non-prerendered routes on the client.When deploying this output to Cloudflare Workers Static Assets, enabling
single-page-applicationcauses unmatched routes to fall back toindex.htmlrather than200.html.As a result, users navigating directly to a non-prerendered route receive the prerendered homepage HTML instead of the intended SPA shell.
This makes it difficult to combine prerendered pages with client-side routes. The current workaround is to use a worker but that means that the website isn't fully static.
All reactions