From e9e8080a8139f898dcfa3c030f5ddaa98413c160 Mon Sep 17 00:00:00 2001 From: Luiz Ferraz Date: Mon, 21 Oct 2024 13:13:52 -0300 Subject: [PATCH] Add server island route to the front of the route list (#12263) * Add server island route to the front of the route list * Add changeset --- .changeset/honest-dots-jump.md | 5 +++++ .../src/pages/[conflicting]/[dynamicRoute].astro | 14 ++++++++++++++ packages/astro/src/core/server-islands/endpoint.ts | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .changeset/honest-dots-jump.md create mode 100644 packages/astro/e2e/fixtures/server-islands/src/pages/[conflicting]/[dynamicRoute].astro diff --git a/.changeset/honest-dots-jump.md b/.changeset/honest-dots-jump.md new file mode 100644 index 000000000000..9ae5d7f1c99f --- /dev/null +++ b/.changeset/honest-dots-jump.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes conflict between server islands and on-demand dynamic routes in the form of `/[...rest]` or `/[paramA]/[paramB]`. diff --git a/packages/astro/e2e/fixtures/server-islands/src/pages/[conflicting]/[dynamicRoute].astro b/packages/astro/e2e/fixtures/server-islands/src/pages/[conflicting]/[dynamicRoute].astro new file mode 100644 index 000000000000..d5ac0379ec76 --- /dev/null +++ b/packages/astro/e2e/fixtures/server-islands/src/pages/[conflicting]/[dynamicRoute].astro @@ -0,0 +1,14 @@ +--- +export const prerender = false; +--- + + + + Conflicting route + + + This route would conflict with the route generated for server islands. +
+ This file is here so the tests break if that happens. + + diff --git a/packages/astro/src/core/server-islands/endpoint.ts b/packages/astro/src/core/server-islands/endpoint.ts index 368a1b9b19ac..e6168b6e0ac6 100644 --- a/packages/astro/src/core/server-islands/endpoint.ts +++ b/packages/astro/src/core/server-islands/endpoint.ts @@ -44,7 +44,7 @@ export function ensureServerIslandRoute(config: ConfigFields, routeManifest: Man return; } - routeManifest.routes.push(getServerIslandRouteData(config)); + routeManifest.routes.unshift(getServerIslandRouteData(config)); } type RenderOptions = {