File tree 3 files changed +6
-6
lines changed
packages/next-auth/src/next
3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change 1
1
import { unstable_getServerSession } from "next-auth/next"
2
- import { authOptions } from "pages/api/auth/[...nextauth]"
3
2
4
3
export default async function Page ( ) {
5
- const session = await unstable_getServerSession ( authOptions )
4
+ const session = await unstable_getServerSession ( )
6
5
return < pre > { JSON . stringify ( session , null , 2 ) } </ pre >
7
6
}
Original file line number Diff line number Diff line change @@ -3,6 +3,6 @@ import { unstable_getServerSession } from "next-auth/next"
3
3
import { authOptions } from "../auth/[...nextauth]"
4
4
5
5
export default async ( req , res ) => {
6
- const session = await unstable_getServerSession ( authOptions )
6
+ const session = await unstable_getServerSession ( req , res , authOptions )
7
7
res . json ( session )
8
8
}
Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ export async function unstable_getServerSession(
94
94
]
95
95
| [ NextApiRequest , NextApiResponse , NextAuthOptions ]
96
96
| [ NextAuthOptions ]
97
+ | [ ]
97
98
) : Promise < Session | null > {
98
99
if ( ! experimentalWarningShown && process . env . NODE_ENV !== "production" ) {
99
100
console . warn (
@@ -105,7 +106,7 @@ export async function unstable_getServerSession(
105
106
experimentalWarningShown = true
106
107
}
107
108
108
- const isRSC = args . length === 1
109
+ const isRSC = args . length === 0 || args . length === 1
109
110
if (
110
111
! experimentalRSCWarningShown &&
111
112
isRSC &&
@@ -122,11 +123,11 @@ export async function unstable_getServerSession(
122
123
123
124
let req , res , options : NextAuthOptions
124
125
if ( isRSC ) {
125
- options = args [ 0 ]
126
+ options = args [ 0 ] ?? { providers : [ ] }
126
127
// eslint-disable-next-line @typescript-eslint/no-var-requires
127
128
const { headers, cookies } = require ( "next/headers" )
128
129
req = {
129
- headers,
130
+ headers : Object . fromEntries ( headers ( ) as Headers ) ,
130
131
cookies : Object . fromEntries (
131
132
cookies ( )
132
133
. getAll ( )
You can’t perform that action at this time.
0 commit comments