-
-
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
Experimental redirects: Dynamic routes interfere with redirects in SSR mode #7581
Comments
@paulrudy Here's how the proposal tackles the dynamic routes: https://github.com/withastro/roadmap/blob/redirects/proposals/redirects.md#dynamic-routes I believe your use case is not handled per design. EDIT: your example doesn't use |
@ematipico The example in the proposal seems to be the opposite of my case:
Unless I'm misunderstanding something, in the example, the named route takes precedence over the spread route. That matches the route priority order. Im my case, the spread filesystem route seems to be taking precedence over the named route in the redirect! That doesn't match the route priority order.
I didn't see anywhere that |
* Update redirects static generation based on recs Got some great recommendations on how to handle our HTML written redirect code based on SEO best practices. See withastro/roadmap#466 (comment) This implements them all. * Fix for using the root path / as a redirect Fixes #7478 * Fix static redirects prefer over dynamic page Fixes #7581
What version of
astro
are you using?2.7.4
Are you using an SSR adapter? If so, which one?
Vercel
What package manager are you using?
pnpm
What operating system are you using?
Mac
What browser are you using?
Chrome, Safari
Describe the Bug
In SSR mode, I'm using a dynamic route
[...slug]
to serve pages from a content collection. I'm also trying to use experimental redirects to redirect specific routes. But the dynamic route seems to supersede the redirects, making them useless.Here's an experimental redirect.
foo.md
doesn't exist, andbar.md
does exist:The redirect is ignored, and navigating to
/foo
results in an error in rendering the dynamic route:Cannot read properties of undefined (reading 'render')
.I'm not sure whether or not this issue is based on a misreading of this line in the docs:
[Edit: now updated to say "same route priority level"]
The way I interpret this line is that, since
Static routes without path parameters will take precedence over all other routes
, if the redirect is a static route, it should be a higher priority than a file-based route with a path or rest parameter. I can't see it making sense any other way.What's the expected result?
The redirect's destination should be the updated parameter for the dynamic route.
From the example, navigating to
/foo
should redirect to/bar
, thus[...slug]
should receivebar
as its parameter.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-z4igp1-ulwjc3?file=astro.config.mjs
Participation
The text was updated successfully, but these errors were encountered: