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) {