-
-
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
Injected SSR routes not following routing priority order #9392
Comments
This might be related to #7721 since both are about problems with I found both bugs while working on the same block of code for Starlight SSR support. |
This isn't something that Astro supports at the moment, although we plan to address it in the coming weeks. |
It looks like a simple fix. The routes are being sorted separately: The routes discovered in the project are sorted before being added to the list of routes:
Then the injected routes are sorted between themselves: astro/packages/astro/src/core/routing/manifest/create.ts Lines 367 to 370 in f47b85c
Then the injected routes are added to the front of the list (explicitly making them overwrite any project route, but this is not documented on astro/packages/astro/src/core/routing/manifest/create.ts Lines 413 to 427 in f47b85c
Personally, I think injected routes should follow the same priority order, so the sorting should be done after both sets of routes are added to the list. We could have an extra option in the As for the priority, this makes Starlight override any and every custom route when running I'm currently patching Astro to have Starlight work properly on the sites I maintain, here is one public (my blog): I can send a PR for this if the proposed design (with the option for controlling) is agreeable. |
We've been wanting to tackle this for a while but haven't had the time to do so. I'm not sure it's a simple fix, however, but closer to a refactor of that module. Currently the file-based routes are sorted during the crawl, not altogether afterwards, which would make it easier to fix. If you want to give this a try though, I think we could figure out a way to do it safely. In addition to injected routes there is also redirects which are similarly sorted separately, after the rest. I would want those to also be sorted together with the other routes. |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
Any browser
Describe the Bug
Non-prerendered routes added by integrations override any existing matching route.
What's the expected result?
The injected route should follow the same route priority order as if it were part of the project.
Link to Minimal Reproducible Example
With project route, working fine: https://stackblitz.com/edit/github-lukzfz-qbzgtv
With injected route, not working: https://stackblitz.com/edit/github-lukzfz-wradsh
Participation
The text was updated successfully, but these errors were encountered: