2.1 KiB
2.1 KiB
Static Assets Routing Patterns
Decide which requests need application logic before choosing configuration. Record expected behavior for public files, API paths, protected content, browser navigation, and missing URLs.
| Routing need | Documentation |
|---|---|
| Serve public assets with minimal Worker involvement | Default Worker routing |
| Combine a SPA with API routes | Advanced SPA routing control |
| Require authentication or transform assets before serving | Run Worker before each request |
| Route an OAuth callback or selected dynamic paths to the Worker | Run Worker first for selective paths |
| Select assets for locale or experiment variants | Asset binding API and Worker-first routing |
| Serve generated HTML with a custom 404 | Custom 404 pages |
| Apply static cache/security headers or redirects | Custom headers and redirects |
Keep public asset paths eligible for direct serving when they do not need application logic. Ensure protected paths cannot bypass the authorization handler through an asset match or navigation fallback. For locale or experiment routing, map accepted variants to known build outputs and define a fallback explicitly.
Use configuration.md for setup and gotchas.md for representative request checks.