From 5a587a6c31db13d0c41b1579a2a0b530efdc8bd0 Mon Sep 17 00:00:00 2001 From: Jiawen Geng Date: Mon, 1 Apr 2024 20:56:40 +0800 Subject: [PATCH] fix: production issue (#4311) * fix: production issue * Update .changeset/soft-tables-ring.md --------- Co-authored-by: Siddharth Suresh --- .changeset/soft-tables-ring.md | 5 +++++ packages/blitz-auth/src/server/auth-sessions.ts | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 .changeset/soft-tables-ring.md diff --git a/.changeset/soft-tables-ring.md b/.changeset/soft-tables-ring.md new file mode 100644 index 0000000000..1c77ff69eb --- /dev/null +++ b/.changeset/soft-tables-ring.md @@ -0,0 +1,5 @@ +--- +"@blitzjs/auth": patch +--- + +Fix bundling issue that occurs in vercel due to the way imports were handled internally diff --git a/packages/blitz-auth/src/server/auth-sessions.ts b/packages/blitz-auth/src/server/auth-sessions.ts index b067b024c6..35f4f90363 100644 --- a/packages/blitz-auth/src/server/auth-sessions.ts +++ b/packages/blitz-auth/src/server/auth-sessions.ts @@ -183,8 +183,7 @@ export async function getSession( export async function getBlitzContext(): Promise { try { - //using eval to avoid bundling next/headers - const {headers, cookies} = eval("require('next/headers')") + const {headers, cookies} = require("next/headers") const req = new IncomingMessage(new Socket()) as IncomingMessage & { cookies: {[key: string]: string} } @@ -234,8 +233,7 @@ export async function useAuthenticatedBlitzContext({ const ctx: Ctx = await getBlitzContext() const userId = ctx.session.userId try { - //using eval to avoid bundling next/navigation - const {redirect} = eval("require('next/navigation')") + const {redirect} = require("next/navigation") if (userId) { debug("[useAuthenticatedBlitzContext] User is authenticated") if (redirectAuthenticatedTo) {