@@ -27,7 +27,10 @@ async function NextAuthApiHandler(
27
27
) {
28
28
const { nextauth, ...query } = req . query
29
29
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
31
34
32
35
const handler = await AuthHandler ( {
33
36
req : {
@@ -71,7 +74,7 @@ async function NextAuthRouteHandler(
71
74
context : RouteHandlerContext ,
72
75
options : AuthOptions
73
76
) {
74
- options . secret ??= process . env . NEXTAUTH_SECRET
77
+ options . secret ??= process . env . NEXTAUTH_SECRET ?? process . env . AUTH_SECRET
75
78
76
79
// eslint-disable-next-line @typescript-eslint/no-var-requires
77
80
const { headers, cookies } = require ( "next/headers" )
@@ -175,7 +178,7 @@ export async function getServerSession<
175
178
O extends GetServerSessionOptions ,
176
179
R = O [ "callbacks" ] extends { session : ( ...args : any [ ] ) => infer U }
177
180
? U
178
- : Session ,
181
+ : Session
179
182
> ( ...args : GetServerSessionParams < O > ) : Promise < R | null > {
180
183
const isRSC = args . length === 0 || args . length === 1
181
184
@@ -198,7 +201,7 @@ export async function getServerSession<
198
201
options = Object . assign ( { } , args [ 2 ] , { providers : [ ] } )
199
202
}
200
203
201
- options . secret ??= process . env . NEXTAUTH_SECRET
204
+ options . secret ??= process . env . NEXTAUTH_SECRET ?? process . env . AUTH_SECRET
202
205
203
206
const session = await AuthHandler < Session | { } | string > ( {
204
207
options,
@@ -233,7 +236,7 @@ export async function unstable_getServerSession<
233
236
O extends GetServerSessionOptions ,
234
237
R = O [ "callbacks" ] extends { session : ( ...args : any [ ] ) => infer U }
235
238
? U
236
- : Session ,
239
+ : Session
237
240
> ( ...args : GetServerSessionParams < O > ) : Promise < R | null > {
238
241
if ( ! deprecatedWarningShown && process . env . NODE_ENV !== "production" ) {
239
242
console . warn (
@@ -250,6 +253,8 @@ declare global {
250
253
namespace NodeJS {
251
254
interface ProcessEnv {
252
255
NEXTAUTH_URL ?: string
256
+ NEXTAUTH_SECRET ?: string
257
+ AUTH_SECRET ?: string
253
258
VERCEL ?: "1"
254
259
}
255
260
}
0 commit comments