diff --git a/.changeset/young-spoons-rescue.md b/.changeset/young-spoons-rescue.md new file mode 100644 index 000000000000..6fbeded05974 --- /dev/null +++ b/.changeset/young-spoons-rescue.md @@ -0,0 +1,5 @@ +--- +'@astrojs/vercel': patch +--- + +Allows the edge middleware to be an async function. 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 `