aleph.js icon indicating copy to clipboard operation
aleph.js copied to clipboard

Routing catches paths in incorrect order

Open ArtemSBulgakov opened this issue 2 years ago • 1 comments

Dynamic routes should not be caught before any other routes.

Example 1

I have the following structure:

/routes/$pageId+.tsx
/routes/posts/index.tsx
/routes/posts/$id.tsx

The route $pageId+ catches all paths. The user cannot get /posts or /posts/$id, these paths are caught by the first route.

Example 2

I have the following structure (notice $pageId without +):

/routes/$pageId.tsx
/routes/posts/index.tsx
/routes/posts/$id.tsx

The user cannot get /posts, that path is caught by the $pageId route (only /posts/index is working for that page).

ArtemSBulgakov avatar Jan 27 '23 20:01 ArtemSBulgakov

I think the following formula should be changed somehow to order dynamic routes after other routes

https://github.com/alephjs/aleph.js/blob/9a103a1babe699ad8c37f217b1bcd626b8a4ee9b/server/routing.ts#L211

ArtemSBulgakov avatar Jan 27 '23 20:01 ArtemSBulgakov