app router + next 14 + next-auth v5 = 404??
Unanswered
Morelet’s Crocodile posted this in #help-forum
Morelet’s CrocodileOP
hiya!
i have a nextjs 14 app with nextauth v5 set up, but i can't navigate to /auth/route - i get a 404.
i have
where
Why is navigating to
If I call
I'm not using the pages router, i'm using the app router from next 13.
i have a nextjs 14 app with nextauth v5 set up, but i can't navigate to /auth/route - i get a 404.
i have
app/api/auth/[...nextauth]/route.ts created with contentsimport { handlers } from "@/auth"; export const { GET, POST } = handlers;where
src/auth.ts isimport NextAuth from "next-auth";
import Google from "next-auth/providers/google";
import type { NextAuthConfig } from "next-auth";
export const config = {
providers: [Google],
basePath: "/auth",
callbacks: {
jwt({ token, trigger, session }) {
if (trigger === "update") token.name = session.user.name;
return token;
},
},
} satisfies NextAuthConfig;
export const { handlers, auth, signIn, signOut } = NextAuth(config);Why is navigating to
http://localhost:3000/auth/signin still throwing a 404?If I call
signIn myself, I still get a 404 when the Google auth redirects tohttp://localhost:3000/auth/callback/google?code=xxxx...I'm not using the pages router, i'm using the app router from next 13.
1 Reply
Morelet’s CrocodileOP
Found & resolved an issue on my end;
app/api/auth/[...nextauth]/route.ts doesn't work, but
app/auth/[...nextauth]/route.ts works perfectly.
app/api/auth/[...nextauth]/route.ts doesn't work, but
app/auth/[...nextauth]/route.ts works perfectly.