export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: 'pg'
}),
basePath: '/api',
baseURL: "BACKEND_REDACTED",
trustedOrigins: ["FRONTEND_REDACTED"],
session: {
expiresIn: 60 * 60 * 24 * 30,
updateAge: 60 * 60 * 24,
},
account: {
encryptOAuthTokens: process.env.NODE_ENV === 'production',
accountLinking: {
enabled: false
}
},
socialProviders: {
twitch: {
clientId: process.env.TWITCH_CLIENT_ID as string,
clientSecret: process.env.TWITCH_CLIENT_SECRET as string,
}
},
plugins: [openAPI()],
experimental: { joins: true },
hooks: {
before: createAuthMiddleware(async (ctx) => {
logger.debug({ path: ctx.path }, 'BetterAuth request received');
}),
after: createAuthMiddleware(async (ctx) => {
logger.debug({ path: ctx.path }, 'BetterAuth request processed');
})
},
advanced: {
defaultCookieAttributes: {
sameSite: "none",
secure: true,
}
}
})
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: 'pg'
}),
basePath: '/api',
baseURL: "BACKEND_REDACTED",
trustedOrigins: ["FRONTEND_REDACTED"],
session: {
expiresIn: 60 * 60 * 24 * 30,
updateAge: 60 * 60 * 24,
},
account: {
encryptOAuthTokens: process.env.NODE_ENV === 'production',
accountLinking: {
enabled: false
}
},
socialProviders: {
twitch: {
clientId: process.env.TWITCH_CLIENT_ID as string,
clientSecret: process.env.TWITCH_CLIENT_SECRET as string,
}
},
plugins: [openAPI()],
experimental: { joins: true },
hooks: {
before: createAuthMiddleware(async (ctx) => {
logger.debug({ path: ctx.path }, 'BetterAuth request received');
}),
after: createAuthMiddleware(async (ctx) => {
logger.debug({ path: ctx.path }, 'BetterAuth request processed');
})
},
advanced: {
defaultCookieAttributes: {
sameSite: "none",
secure: true,
}
}
})