Skip to content

Commit

Permalink
Allow async functions in the Vercel edge middleware integration (#9334)
Browse files Browse the repository at this point in the history
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com>
Co-authored-by: lilnasy <69170106+lilnasy@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 7, 2023
1 parent 3e4109b commit dfbc707
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/young-spoons-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/vercel': patch
---

Allows the edge middleware to be an async function.
2 changes: 1 addition & 1 deletion packages/integrations/vercel/src/serverless/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 `
Expand Down

0 comments on commit dfbc707

Please sign in to comment.