Skip to content

Commit

Permalink
SSR doesn't need to block multiple routes that match the same URL (#4329
Browse files Browse the repository at this point in the history
)

* fix: SSR doesn't need to block multiple routes that match the same URL

* chore: add changeset
  • Loading branch information
Tony Sullivan committed Aug 15, 2022
1 parent fbf9752 commit 0274b8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-llamas-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Updates routing logic to allow multiple routes to match the same URL in SSR
7 changes: 0 additions & 7 deletions packages/astro/src/vite-plugin-astro-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,6 @@ async function handleRequest(
async function matchRoute() {
const matches = matchAllRoutes(pathname, manifest);

if (config.output === 'server' && matches.length > 1) {
throw new Error(`Found multiple matching routes for "${pathname}"! When using \`output: 'server'\`, only one route in \`src/pages\` can match a given URL. Found:
${matches.map(({ component }) => `- ${component}`).join('\n')}
`);
}

for await (const maybeRoute of matches) {
const filePath = new URL(`./${maybeRoute.component}`, config.root);
const preloadedComponent = await preload({ astroConfig: config, filePath, viteServer });
Expand Down

0 comments on commit 0274b8d

Please sign in to comment.