For single page apps, how can we rewrite 404s to the index.html?

Single page applications have client side routing, so it need to load the JS before being able to route properly. Is there a way to rewrite a 404 status code to always server index.html? I know this is possible in AWS S3/CloudFront, but I don’t know how to do it on render.

HI there,

Thanks for reaching out.

Static Site Redirects and Rewrites should help you achieve this. The Wildcard rewrite rule is likely what you’ll need for a single page app.

Hope that helps

Kind regards

Alan

1 Like