Skip to content
This repository has been archived by the owner on Jan 28, 2025. It is now read-only.

Incorrect routing precedence for SSR #967

Closed
darren-charterindex opened this issue Mar 26, 2021 · 4 comments
Closed

Incorrect routing precedence for SSR #967

darren-charterindex opened this issue Mar 26, 2021 · 4 comments

Comments

@darren-charterindex
Copy link

darren-charterindex commented Mar 26, 2021

hello, I am seeing catch-all routes taking priority over dynamic routes on the SSR.

For example:

A request for /products/123

CSR (correct)

/pages/example
/pages/products/[id] <- renders
/pages/[...slugs] 

SSR (incorrect)

/pages/example
/pages/products/[id]
/pages/[...slugs] <- renders

A request for /parent/child

CSR (correct)

/pages/example
/pages/products/[id]
/pages/[...slugs] <- renders

SSR (correct)

/pages/example
/pages/products/[id]
/pages/[...slugs] <- renders

A request for /example

CSR (correct)

/pages/example <- renders
/pages/products/[id]
/pages/[...slugs]

SSR (correct)

/pages/example <- renders
/pages/products/[id]
/pages/[...slugs]

It is my understanding that the precedence for routes should be predefined > dynamic > catch-all > optional-catch-all

https://nextjs.org/docs/routing/dynamic-routes#caveats

This is happening on [email protected] and serverless-next.js@@1.19.0-alpha.39.

@dphang
Copy link
Collaborator

dphang commented Mar 30, 2021

I think this should fix it: #974 - published in latest alpha. I think the cause is all dynamic routes are grouped together (including catch all), so if catch all is resolved first before other dynamic routes, the precedence may be wrong. It is tested in e2e tests but somehow (maybe due to naming of routes causing a coincidentally correct order?), the catch all always came after, so it happened to work. The fix will separate them distinctly so at runtime, we can try to match all dynamic routes before catch all routes. Non-dynamic/predefined routes should already be matched correctly.

@dphang dphang closed this as completed Mar 30, 2021
@mdsavian
Copy link

mdsavian commented Apr 1, 2021

It still doesn't work for me. When I do a build, these files are generated, but are not copied to serverless

image

Serverless folder

image

@dphang
Copy link
Collaborator

dphang commented Apr 1, 2021

@mdsavian sorry I am not sure which issue you are talking about, seems not related to catch all route precedence? Could you please open an issue with more context include versions, serverless.yml file and what you are trying to do. Thanks!

@darren-charterindex this is published in latest version, please comment in case of any issues

@mdsavian
Copy link

mdsavian commented Apr 1, 2021

I fall into a new issue with ISG revalidation, so I wait until #804 is resolved, thanks :D

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants