Skip to content

Commit

Permalink
Remove status check and instead check body is not a string
Browse files Browse the repository at this point in the history
  • Loading branch information
melanieseltzer committed Aug 31, 2022
1 parent 26d7648 commit 67b6395
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/next-auth/src/next/index.ts
Expand Up @@ -107,7 +107,7 @@ export async function unstable_getServerSession(

options.secret = options.secret ?? process.env.NEXTAUTH_SECRET

const session = await NextAuthHandler<Session | {}>({
const session = await NextAuthHandler<Session | {} | string>({
options,
req: {
host: detectHost(req.headers["x-forwarded-host"]),
Expand All @@ -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
}
Expand Down

0 comments on commit 67b6395

Please sign in to comment.