File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
packages/next-auth/src/lib Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -15,12 +15,17 @@ export function reqWithEnvURL(req: NextRequest): NextRequest {
1515 * For backwards compatibility, `next-auth` checks for `NEXTAUTH_URL`
1616 * and the `basePath` by default is `/api/auth` instead of `/auth`
1717 * (which is the default for all other Auth.js integrations).
18+ *
19+ * For the same reason, `NEXTAUTH_SECRET` is also checked.
1820 */
1921export function setEnvDefaults ( config : NextAuthConfig ) {
2022 try {
23+ config . secret ??= process . env . AUTH_SECRET ?? process . env . NEXTAUTH_SECRET
2124 const url = process . env . AUTH_URL ?? process . env . NEXTAUTH_URL
2225 if ( ! url ) return
23- config . basePath ||= new URL ( url ) . pathname
26+ const { pathname } = new URL ( url )
27+ if ( pathname === "/" ) return
28+ config . basePath ||= pathname
2429 } catch {
2530 } finally {
2631 config . basePath ||= "/api/auth"
You can’t perform that action at this time.
0 commit comments