NextAuth on create.t3 rendering a server error | maybe a dumb question </3
it is the first time that i'm using t3 stack, I have setup everything with Google oAuth but the localhost is showing me "Server Error" after the google oAuth screens. The console shows me this:
[auth][details]: {}
GET /api/auth/callback/google?code=4%2F0AVMBsJhKNdt6RN4yjbzTjwh_p9JkVHZo4EYryFuOT62Msrb4OmiCLK2lk1O_2kqGdkwO3g&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+openid&authuser=0&prompt=consent 302 in 426ms
GET /api/auth/error?error=Configuration 500 in 62ms
[auth][details]: {}
GET /api/auth/callback/google?code=4%2F0AVMBsJhKNdt6RN4yjbzTjwh_p9JkVHZo4EYryFuOT62Msrb4OmiCLK2lk1O_2kqGdkwO3g&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+openid&authuser=0&prompt=consent 302 in 426ms
GET /api/auth/error?error=Configuration 500 in 62ms

2 Replies
Without more info, it's hard to tell, but the fact that it says the error is 'configuration' likely means you've set up NextAuth incorrectly.
sure, this is my NextAuth config:
if you want to see things, let me know
thats the schema for the users table:
nvm, i'm using clerk now
import { PrismaAdapter } from "@auth/prisma-adapter";
import { type DefaultSession, type NextAuthConfig } from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import { db } from "~/server/db";
/**
* Module augmentation for `next-auth` types. Allows us to add custom properties to the `session`
* object and keep type safety.
*
* @see https://next-auth.js.org/getting-started/typescript#module-augmentation
*/
declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
// ...other properties
// role: UserRole;
} & DefaultSession["user"];
}
// interface User {
// // ...other properties
// // role: UserRole;
// }
}
/**
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
*
* @see https://next-auth.js.org/configuration/options
*/
export const authConfig = {
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
authorization: {
params: {
prompt: "consent",
access_type: "offline",
response_type: "code"
}
}
})
],
secret: process.env.AUTH_SECRET,
adapter: PrismaAdapter(db),
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
},
}),
},
} satisfies NextAuthConfig;
import { PrismaAdapter } from "@auth/prisma-adapter";
import { type DefaultSession, type NextAuthConfig } from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import { db } from "~/server/db";
/**
* Module augmentation for `next-auth` types. Allows us to add custom properties to the `session`
* object and keep type safety.
*
* @see https://next-auth.js.org/getting-started/typescript#module-augmentation
*/
declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
// ...other properties
// role: UserRole;
} & DefaultSession["user"];
}
// interface User {
// // ...other properties
// // role: UserRole;
// }
}
/**
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
*
* @see https://next-auth.js.org/configuration/options
*/
export const authConfig = {
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
authorization: {
params: {
prompt: "consent",
access_type: "offline",
response_type: "code"
}
}
})
],
secret: process.env.AUTH_SECRET,
adapter: PrismaAdapter(db),
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
},
}),
},
} satisfies NextAuthConfig;
model User {
id String @id @default(uuid()) @map("id")
name String?
firstName String? @map("first_name")
lastName String? @map("last_name")
postcode String?
avatar String?
email String @unique
phoneNumber String? @map("phone_number")
aboutMe String? @map("about_me")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
mortgageAdvisor MortgageAdvisor? // One-to-one or one-to-many, depending on if a user can be multiple advisors
lawyer Lawyer? // One-to-one or one-to-many
postedProperties Property[]
savedProperties UserSavedProperty[]
enquiriesMade Enquiry[] @relation("Enquirer") // User who made the enquiry
enquiriesManaged Enquiry[] @relation("Agent") // User who is the agent for the enquiry
}
model User {
id String @id @default(uuid()) @map("id")
name String?
firstName String? @map("first_name")
lastName String? @map("last_name")
postcode String?
avatar String?
email String @unique
phoneNumber String? @map("phone_number")
aboutMe String? @map("about_me")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
mortgageAdvisor MortgageAdvisor? // One-to-one or one-to-many, depending on if a user can be multiple advisors
lawyer Lawyer? // One-to-one or one-to-many
postedProperties Property[]
savedProperties UserSavedProperty[]
enquiriesMade Enquiry[] @relation("Enquirer") // User who made the enquiry
enquiriesManaged Enquiry[] @relation("Agent") // User who is the agent for the enquiry
}