auth.api.getSession() Causing Issue on Vercel Build

i am trying to fetch the user session on the server to do some stuff with it and it works fine when running in locally, but when i build it on Vercel edge function and deploy it, it gives me a server error saying I'm calling localhost? I assumed maybe its the env variable so i logged it in build time and it is the correct domain what could the issue be?
No description
No description
2 Replies
nikatune
nikatune3mo ago
can you send your auth config?=
abiyM
abiyMOP3mo ago
const options = {
plugins: [
//...plugins
]
} satisfies BetterAuthOptions;
export const auth = betterAuth({
plugins: [
...(options.plugins ?? []),
customSession(async ({ user, session }, ctx) => {
// @ts-ignore
const organization = await getUserOrganizations(user.id);
return {
user,
session,
organization
};
}, options)
],
trustedOrigins: [
process.env.CROSS_BETTER_AUTH_URL_1,
process.env.CROSS_BETTER_AUTH_URL_2,
process.env.CROSS_BETTER_AUTH_URL_3,
],
database: drizzleAdapter(db, {
provider: 'pg',
schema,
}),
emailAndPassword: {
requireEmailVerification: true,
enabled: true,
autoSignIn: true,
minPasswordLength: 8,
maxPasswordLength: 20,
},
user:{
additionalFields:{
username:{
type: "string",
required: true,
unique: true,
input: true,
},
is_verified:{
type: "boolean",
required: false,
input: false
},
role_id:{
type: "number",
defaultValue: "user",
input: false,
}
}
},

})
const options = {
plugins: [
//...plugins
]
} satisfies BetterAuthOptions;
export const auth = betterAuth({
plugins: [
...(options.plugins ?? []),
customSession(async ({ user, session }, ctx) => {
// @ts-ignore
const organization = await getUserOrganizations(user.id);
return {
user,
session,
organization
};
}, options)
],
trustedOrigins: [
process.env.CROSS_BETTER_AUTH_URL_1,
process.env.CROSS_BETTER_AUTH_URL_2,
process.env.CROSS_BETTER_AUTH_URL_3,
],
database: drizzleAdapter(db, {
provider: 'pg',
schema,
}),
emailAndPassword: {
requireEmailVerification: true,
enabled: true,
autoSignIn: true,
minPasswordLength: 8,
maxPasswordLength: 20,
},
user:{
additionalFields:{
username:{
type: "string",
required: true,
unique: true,
input: true,
},
is_verified:{
type: "boolean",
required: false,
input: false
},
role_id:{
type: "number",
defaultValue: "user",
input: false,
}
}
},

})
left out some parts that i didnt think wass nessary cuz of discords message limit i really apologize! I figured out the problem was calling getUserOrganizations

Did you find this page helpful?