Single page applications, redirect all routes to a single .html
file. Different hostings provide different ways to set this fallback:
Netlify: _redirects
:
/* /index.html 200
Vercel: vercel.json
:
{
"rewrites": [
{ "source": "/(.*)", "destination": "/index.html" }
]
}
Github pages: 404.html
:
(no extra config needed)
Firebase hosting: firebase.json
:
{
"hosting": {
"rewrites": [
{ "source": "**", "destination": "/index.html" }
]
}
}
Cloudflare pages: _redirects
/* /index.html 200
While it actually works with wrangler deploy
and in production redirects happen (working deployment), there is warning for wrangler dev
:
▲ [WARNING] Found 1 invalid redirect rule:
▶︎ Valid status codes are 200, 301, 302 (default), 303, 307, or 308. Got 404.
at dist/_redirects:1 | /* /404.html 404
And this is also despite current docs:
Feature | Support | Example | Notes |
---|---|---|---|
Rewrites (other status codes) | NO | /blog/* /blog/404.html 404 |
This repo is prepared to report this mismatch behavior.