@@ -27,7 +27,10 @@ async function NextAuthApiHandler(
2727) {
2828 const { nextauth, ...query } = req . query
2929
30- options . secret ??= options . jwt ?. secret ?? process . env . NEXTAUTH_SECRET
30+ options . secret ??=
31+ options . jwt ?. secret ??
32+ process . env . NEXTAUTH_SECRET ??
33+ process . env . AUTH_SECRET
3134
3235 const handler = await AuthHandler ( {
3336 req : {
@@ -71,7 +74,7 @@ async function NextAuthRouteHandler(
7174 context : RouteHandlerContext ,
7275 options : AuthOptions
7376) {
74- options . secret ??= process . env . NEXTAUTH_SECRET
77+ options . secret ??= process . env . NEXTAUTH_SECRET ?? process . env . AUTH_SECRET
7578
7679 // eslint-disable-next-line @typescript-eslint/no-var-requires
7780 const { headers, cookies } = require ( "next/headers" )
@@ -175,7 +178,7 @@ export async function getServerSession<
175178 O extends GetServerSessionOptions ,
176179 R = O [ "callbacks" ] extends { session : ( ...args : any [ ] ) => infer U }
177180 ? U
178- : Session ,
181+ : Session
179182> ( ...args : GetServerSessionParams < O > ) : Promise < R | null > {
180183 const isRSC = args . length === 0 || args . length === 1
181184
@@ -198,7 +201,7 @@ export async function getServerSession<
198201 options = Object . assign ( { } , args [ 2 ] , { providers : [ ] } )
199202 }
200203
201- options . secret ??= process . env . NEXTAUTH_SECRET
204+ options . secret ??= process . env . NEXTAUTH_SECRET ?? process . env . AUTH_SECRET
202205
203206 const session = await AuthHandler < Session | { } | string > ( {
204207 options,
@@ -233,7 +236,7 @@ export async function unstable_getServerSession<
233236 O extends GetServerSessionOptions ,
234237 R = O [ "callbacks" ] extends { session : ( ...args : any [ ] ) => infer U }
235238 ? U
236- : Session ,
239+ : Session
237240> ( ...args : GetServerSessionParams < O > ) : Promise < R | null > {
238241 if ( ! deprecatedWarningShown && process . env . NODE_ENV !== "production" ) {
239242 console . warn (
@@ -250,6 +253,8 @@ declare global {
250253 namespace NodeJS {
251254 interface ProcessEnv {
252255 NEXTAUTH_URL ?: string
256+ NEXTAUTH_SECRET ?: string
257+ AUTH_SECRET ?: string
253258 VERCEL ?: "1"
254259 }
255260 }
0 commit comments