-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong params and route when index is server side rendered #9757
Comments
I've identified the same problem with |
Do you mean that in v4.2.0 this worked as expected? |
yes, in my project i've used the pinned |
same problem |
Hey everyone, sorry for the inconvenience this has caused. This was working previously only due to an inconsistency to how some routes were prioritized, being considered higher priority for some things and lower priority for other things. Specially when rest parameters were involved. Defining how routes are ordered without relying on file-system details revealed those inconsistencies that Astro and users were relying on without noticing. For example, an You can see the opposite problem on #9726 that was caused by 4.2.0, the fix for that on 4.2.1 cause this problem here. We are discussing whether the index page should have a special behavior that handles this case. For now, the easiest workaround is to use |
@Fryuni are you sure this is not a bug? I have a similar case: minimal Stackblitz repro. But basically ![]() Unfortunately, the docs don't really spell out what happens if some of the rules in the precedence order are in conflict... |
The first rule in your link already explains why the index wins in your scenario; it has more segments. Those rules are applied in order. The same solution of using Using rest parameters anywhere but the last part of the path will lead to confusion because it creates a more specific route (which is a higher priority) that matches a less specific, shorter path. As I mentioned, this problem already existed, and some people just happened not to hit it because they relied on an inconsistency. For example, consider these files:
What should the This problem was already present in previous versions of Astro. The difference is that it happened due to an implementation detail and not because of an established rule. There are possible solutions for the index page, but for the example above there isn't a solution that is always right. |
Hey @Fryuni i did not use the
If i call the |
That is still 3 segments vs 2 segments. But thank you, I'm taking notice of these use cases to propose a fix that makes the intuitive sense for most cases even though it won't be the most intuitive for all cases. Your case replacing |
Yes, this workaround will do the trick for now. |
I think it would be better if developers had the option to create and extend routes manually in complex cases |
Seems I forgot to link this issue. It should be fixed by #9786 as well |
Upgrading reproduction's astro version to |
It works for me, thank you. But there is another problem with |
Sorry about that, we're really making our best! Feel free to open another issue! |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
Chrome, Firefox, Safari
Describe the Bug
Open page /en/about
In case when page
[...lang]/index
is SSR rendered page other pages in this folder works wrongFor example page
[...lang]/about
is renders[...lang]/index
with langAstro.params.lang = en/about
Change
export const prerender = false
totrue
will fix this problemIn astro version 3 this works as expected
What's the expected result?
Render about
[...lang]/about
withAstro.params.lang = en
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-zvp3wm
Participation
The text was updated successfully, but these errors were encountered: