Skip to content

Commit 5a8b029

Browse files
committed
docs: clarify getToken + secret in example
ref #4954
1 parent f62a985 commit 5a8b029

File tree

2 files changed

+4
-4
lines changed
  • apps
    • dev/pages/api/examples
    • example-nextjs/pages/api/examples

2 files changed

+4
-4
lines changed

apps/dev/pages/api/examples/jwt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
import { getToken } from "next-auth/jwt"
33

44
export default async (req, res) => {
5-
const token = await getToken({ req, secret: process.env.SECRET })
5+
const token = await getToken({ req })
66
res.send(JSON.stringify(token, null, 2))
77
}

apps/example-nextjs/pages/api/examples/jwt.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { getToken } from "next-auth/jwt"
33

44
import type { NextApiRequest, NextApiResponse } from "next"
55

6-
const secret = process.env.NEXTAUTH_SECRET
7-
86
export default async function handler(
97
req: NextApiRequest,
108
res: NextApiResponse
119
) {
12-
const token = await getToken({ req, secret })
10+
// If you don't have the NEXTAUTH_SECRET environment variable set,
11+
// you will have to pass your secret as `secret` to `getToken`
12+
const token = await getToken({ req })
1313
res.send(JSON.stringify(token, null, 2))
1414
}

0 commit comments

Comments
 (0)