From a013182d322a3969e39d647aad75ec10f8bd1ed7 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 23 Feb 2024 09:13:10 -0500 Subject: [PATCH] Fixes edge middleware calling nested routes (#10215) --- .changeset/popular-turtles-sort.md | 5 +++++ packages/integrations/vercel/src/serverless/middleware.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/popular-turtles-sort.md diff --git a/.changeset/popular-turtles-sort.md b/.changeset/popular-turtles-sort.md new file mode 100644 index 000000000000..326b786419cb --- /dev/null +++ b/.changeset/popular-turtles-sort.md @@ -0,0 +1,5 @@ +--- +"@astrojs/vercel": patch +--- + +Fixes edge middleware calling nested routes diff --git a/packages/integrations/vercel/src/serverless/middleware.ts b/packages/integrations/vercel/src/serverless/middleware.ts index 91d03287371a..bf38a3a9f4c0 100644 --- a/packages/integrations/vercel/src/serverless/middleware.ts +++ b/packages/integrations/vercel/src/serverless/middleware.ts @@ -90,7 +90,7 @@ export default async function middleware(request, context) { ctx.locals = ${handlerTemplateCall}; const { origin } = new URL(request.url); const next = () => - fetch(new URL('${NODE_PATH}', request.url), { + fetch(new URL('/${NODE_PATH}', request.url), { headers: { ...Object.fromEntries(request.headers.entries()), '${ASTRO_MIDDLEWARE_SECRET_HEADER}': '${middlewareSecret}',