-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Changed basePath in auth.ts to match the official documentation #13166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…/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.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
@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", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
(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:
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
🎫 Affected issues
N/A
📌 Resources