Skip to content

Commit

Permalink
fix: production issue (#4311)
Browse files Browse the repository at this point in the history
* fix: production issue

* Update .changeset/soft-tables-ring.md

---------

Co-authored-by: Siddharth Suresh <[email protected]>
  • Loading branch information
gengjiawen and siddhsuresh authored Apr 1, 2024
1 parent 744242f commit 5a587a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/soft-tables-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blitzjs/auth": patch
---

Fix bundling issue that occurs in vercel due to the way imports were handled internally
6 changes: 2 additions & 4 deletions packages/blitz-auth/src/server/auth-sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ export async function getSession(

export async function getBlitzContext(): Promise<Ctx> {
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}
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 5a587a6

Please sign in to comment.