Skip to content

Conversation

jeremyko
Copy link

@jeremyko jeremyko commented Aug 9, 2025

(Next.js v15.4.6)
The official documentation (https://authjs.dev/guides/configuring-github) suggests setting the Callback URL to "http://localhost:3000/api/auth/callback/github", but the official example (apps/examples/nextjs) doesn't include an api folder. need to change the basePath in auth.ts to match the documentation (/api/auth). Also, when running the prettier command, if the path contains "[...]", the following error occurs:

[error] No files matching the pattern were found: "'apps/examples/nextjs/app/api/auth/[...nextauth]/route.ts'".

So, I added a path exception to lefthook.yml. There may be another way.

☕️ Reasoning

Modified the Next.js example to match the official documentation.

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

N/A

📌 Resources

…/auth")

(Next.js v15.4.6)
The official documentation (https://authjs.dev/guides/configuring-github) suggests
setting the Callback URL to "http://localhost:3000/api/auth/callback/github",
but the official example (https://github.com/nextauthjs/next-auth-example) doesn't include an api folder.
need to change the basePath in auth.ts to match the documentation.
Also, when running the prettier command, if the path contains "[...]", the following error occurs:

    [error] No files matching the pattern were found: "'apps/examples/nextjs/app/api/auth/[...nextauth]/route.ts'".

So, I added a path exception to lefthook.yml. This doesn't seem to be the best solution. There may be another way.
Copy link

vercel bot commented Aug 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 9, 2025 5:03am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Aug 9, 2025 5:03am

Copy link

vercel bot commented Aug 9, 2025

@jeremyko is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

@@ -100,7 +100,7 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
WorkOS({ connection: process.env.AUTH_WORKOS_CONNECTION! }),
Zoom,
],
basePath: "/auth",
basePath: "/api/auth",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The basePath option was configured to point to auth/[...nextauth] instead of api/auth/[...nextauth]. As you noted, the configuration is in auth/[...nextauth]/route.ts, not api/auth/[...nextauth].

import { handlers } from "auth"
export const { GET, POST } = handlers

​The NextAuth.js documentation recommends using the api/auth structure. However, this isn't a strict requirement, as the basePath option was introduced specifically to allow for custom authentication routes. The user isn't obligated to configure their app with /api/auth.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, then I think the official documentation (https://authjs.dev/guides/configuring-github) needs to be revised. To avoid confusion, the documentation should explicitly specify "http://localhost:3000/auth/callback/github." We develop our code by referencing both the official documentation and the examples. It would be best if one of the two were revised to eliminate any inconsistencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants