From 67b6395b2c7261553e4a6fe0a71aa0109c1a41be Mon Sep 17 00:00:00 2001 From: Melanie Seltzer Date: Tue, 30 Aug 2022 18:11:51 -0700 Subject: [PATCH] Remove status check and instead check body is not a string --- packages/next-auth/src/next/index.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/next-auth/src/next/index.ts b/packages/next-auth/src/next/index.ts index d25ff649ab..567e8432ec 100644 --- a/packages/next-auth/src/next/index.ts +++ b/packages/next-auth/src/next/index.ts @@ -107,7 +107,7 @@ export async function unstable_getServerSession( options.secret = options.secret ?? process.env.NEXTAUTH_SECRET - const session = await NextAuthHandler({ + const session = await NextAuthHandler({ options, req: { host: detectHost(req.headers["x-forwarded-host"]), @@ -118,13 +118,12 @@ export async function unstable_getServerSession( }, }) - const { body, cookies, status } = session + const { body, cookies } = session cookies?.forEach((cookie) => setCookie(res, cookie)) - const error = status && status !== 200 - - if (!error && body && Object.keys(body).length) return body as Session + if (body && typeof body !== "string" && Object.keys(body).length) + return body as Session return null }