Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/examples/nextjs/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

session: { strategy: "jwt" },
callbacks: {
authorized({ request, auth }) {
Expand Down
2 changes: 2 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ pre-commit:
commands:
format:
run: pnpm prettier --cache --write {staged_files}
exclude:
- apps/examples/nextjs/app/api/auth/*
stage_fixed: true