Don't handle /outfits/new with SSR

Right, the routes are a bit confusing, `/outfits/new` matches `/outfits/:id`, but shouldn't.

I fix this at the routing level, by creating a more specific `/outfits/new` route that matches first, and just serves `index.html` right from the CDN.

To check that it's exact, I check for either a `?` or the end-of-string after `new`. That way, `/outfits/newish` correctly redirects to the SSR. (This doesn't actually matter a lot, because outfit IDs are only ever numbers and therefore can't start with "new"? But I figure, better to have an unambiguous semantic, then leave random things relying on outfit ID format assumptions.)
This commit is contained in:
Emi Matchu 2021-05-14 20:35:24 -07:00
parent d31809cc62
commit 2bc2fc5bfe

View file

@ -1,5 +1,6 @@
{ {
"routes": [ "routes": [
{ "src": "/outfits/new(\\?|$)", "dest": "/index.html" },
{ "src": "/outfits/(?<id>[^/]*)", "dest": "/api/outfitPageSSR.js?id=$id" }, { "src": "/outfits/(?<id>[^/]*)", "dest": "/api/outfitPageSSR.js?id=$id" },
{ {
"handle": "filesystem" "handle": "filesystem"