From ace5cf9f67dc540757bf2831a154252ebce158ba Mon Sep 17 00:00:00 2001 From: Geoffrey Casper Date: Wed, 6 Dec 2023 01:16:58 +0000 Subject: [PATCH 1/3] allow async functions in edge middleware Vercel's Edge Middleware allows async functions so should the Astro wrapper. --- .changeset/young-spoons-rescue.md | 5 +++++ packages/integrations/vercel/package.json | 2 +- packages/integrations/vercel/src/serverless/middleware.ts | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/young-spoons-rescue.md diff --git a/.changeset/young-spoons-rescue.md b/.changeset/young-spoons-rescue.md new file mode 100644 index 000000000000..bb6f39c03c67 --- /dev/null +++ b/.changeset/young-spoons-rescue.md @@ -0,0 +1,5 @@ +--- +'@astrojs/vercel': minor +--- + +Allow async functions in the Vercel edge middleware integration. diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index 730020c04762..34be8cd3e805 100644 --- a/packages/integrations/vercel/package.json +++ b/packages/integrations/vercel/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/vercel", "description": "Deploy your site to Vercel", - "version": "6.0.0", + "version": "6.1.0", "type": "module", "author": "withastro", "license": "MIT", diff --git a/packages/integrations/vercel/src/serverless/middleware.ts b/packages/integrations/vercel/src/serverless/middleware.ts index a2e44722b20d..b3ada80d15bf 100644 --- a/packages/integrations/vercel/src/serverless/middleware.ts +++ b/packages/integrations/vercel/src/serverless/middleware.ts @@ -53,7 +53,7 @@ function edgeMiddlewareTemplate(middlewarePath: string, vercelEdgeMiddlewareHand if (existsSync(filePathEdgeMiddleware + '.js') || existsSync(filePathEdgeMiddleware + '.ts')) { const stringified = JSON.stringify(filePathEdgeMiddleware.replace(/\\/g, '/')); handlerTemplateImport = `import handler from ${stringified}`; - handlerTemplateCall = `handler({ request, context })`; + handlerTemplateCall = `await handler({ request, context })`; } else { } return ` From ec8d618d858c6e153a73034bda1a662b61e24fa1 Mon Sep 17 00:00:00 2001 From: Geoffrey Casper Date: Wed, 6 Dec 2023 16:21:55 -0500 Subject: [PATCH 2/3] fix changeset wording Co-authored-by: Florian Lefebvre --- .changeset/young-spoons-rescue.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/young-spoons-rescue.md b/.changeset/young-spoons-rescue.md index bb6f39c03c67..736f3bf98d4d 100644 --- a/.changeset/young-spoons-rescue.md +++ b/.changeset/young-spoons-rescue.md @@ -2,4 +2,4 @@ '@astrojs/vercel': minor --- -Allow async functions in the Vercel edge middleware integration. +Allows the edge middleware to be an async function. From 5ba92f1d09a38ec4ae0db97e610d33d22b588ffb Mon Sep 17 00:00:00 2001 From: Geoffrey Casper Date: Wed, 6 Dec 2023 17:44:50 -0500 Subject: [PATCH 3/3] small changes get patches Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com> --- .changeset/young-spoons-rescue.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/young-spoons-rescue.md b/.changeset/young-spoons-rescue.md index 736f3bf98d4d..6fbeded05974 100644 --- a/.changeset/young-spoons-rescue.md +++ b/.changeset/young-spoons-rescue.md @@ -1,5 +1,5 @@ --- -'@astrojs/vercel': minor +'@astrojs/vercel': patch --- Allows the edge middleware to be an async function.