tldraw/apps
Dan Groshev a8999aa0a0
Make Vercel URL rewrites precise (#2913)
### The problem

Right now we use a catchall path in Vercel routing config to rewrite all
requests that don't match existing assets to `/index.html`, which is
needed for client side routing to work. This, however, messes up 404
errors for truly non-existing files which won't be handled by the SPA,
because they get redirected to index.html.

Even worse, this interacts very poorly with caching. Normally if we
request a non-existent file, then put the file in place, and request the
file again, we'll get 404 the first time and the actual file the second
time. However, in our case we instead return `/index.html` after the
first attempt and cache that response, making it impossible to correct a
missing file without cache flush.

### The solution

One way to fix this is to make the regex in Vercel config precise, so
that they only match our SPA routes. However, it can be dangerous,
because this means we'll need to manually update the config with new SPA
routes every time we add any. This PR tests that regexes we're using in
Vercel match all routes that we set in the SPA router.

### Potential future improvements

It's very possible to generate Vercel's config from React Router routing
objects, but at the moment it's not done because that would require
importing most of dotcom during the build phase, which seem to cause
errors.

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package[^2]

### Test Plan

1. Might need a light smoke test after deployment to dotcom.

- [x] End to end tests
2024-02-22 18:25:45 +00:00
..
docs Better example intros (#2912) 2024-02-22 09:05:35 +00:00
dotcom Make Vercel URL rewrites precise (#2913) 2024-02-22 18:25:45 +00:00
dotcom-asset-upload Faster validations + record reference stability at the same time (#2848) 2024-02-20 12:35:25 +00:00
dotcom-bookmark-extractor Bump Yarn to 4.0.2 and add version constraints (#2481) 2024-01-18 11:09:17 +00:00
dotcom-worker Check tsconfig "references" arrays (#2891) 2024-02-21 13:07:53 +00:00
examples Bounds snapping shape (#2909) 2024-02-22 17:10:50 +00:00
health-worker Check tsconfig "references" arrays (#2891) 2024-02-21 13:07:53 +00:00
huppy Check tsconfig "references" arrays (#2891) 2024-02-21 13:07:53 +00:00
vscode VS Code 2.0.25 (#2911) 2024-02-22 08:50:14 +00:00