Skip to content

Commit 180c625

Browse files
committedNov 6, 2022
fix(next): build RSC+unstable_getServerSession
1 parent 362e981 commit 180c625

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed
 

‎packages/next-auth/src/next/index.ts

+2-14
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ export async function unstable_getServerSession(
124124
const [req, res, options] = isRSC
125125
? [
126126
{
127-
headers: ensureAvailable(headers),
128-
cookies: ensureAvailable(nextCookies)
127+
headers: headers(),
128+
cookies: nextCookies()
129129
.getAll()
130130
.reduce((acc, c) => ({ ...acc, [c.name]: c.value }), {}),
131131
} as any,
@@ -172,15 +172,3 @@ declare global {
172172
}
173173
}
174174
}
175-
176-
function ensureAvailable(fn: () => any) {
177-
try {
178-
return fn()
179-
} catch (error) {
180-
console.error(error)
181-
console.error(
182-
`Could not access ${fn.name}(). If you are not in a React Server Cmponent, pass the request and response.`
183-
)
184-
// Cannot throw since Next.js expects DynamicServerError
185-
}
186-
}

0 commit comments

Comments
 (0)
Please sign in to comment.