Skip to content

Commit b8506cd

Browse files
committed
fix: update authentication base URL to use environment variable
- Changed the base URL for authentication to utilize the BETTER_AUTH_URL environment variable, providing flexibility for different environments. - Added optional parameters for Google authentication to support offline access and account selection, enhancing user experience during login.
1 parent b3f261a commit b8506cd

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/lib/auth.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const auth = betterAuth({
2424
usePlural: true, // Use plural collection names (users) to match backend Mongoose model
2525
}),
2626
// baseURL should be the backend server URL, not frontend
27-
baseURL: "https://api.boundlessfi.xyz",
27+
baseURL: process.env.BETTER_AUTH_URL || "https://api.boundlessfi.xyz",
2828
// basePath: "/api/auth",
2929
emailAndPassword: {
3030
enabled: true,
@@ -80,6 +80,16 @@ export const auth = betterAuth({
8080
google: {
8181
clientId: config.GOOGLE_CLIENT_ID,
8282
clientSecret: config.GOOGLE_CLIENT_SECRET,
83+
// Optional: Always ask user to select an account (useful for multi-account users)
84+
// Uncomment to enable:
85+
// prompt: "select_account",
86+
87+
// Optional: Always get refresh token (required for offline access to Google APIs)
88+
// Note: Google only issues refresh token on first consent. To get a new refresh token,
89+
// users must revoke app access in their Google account settings, then re-authorize.
90+
// Uncomment both lines to enable:
91+
accessType: "offline",
92+
prompt: "select_account consent", // Required with accessType: "offline"
8393
},
8494
github: {
8595
clientId: config.GITHUB_CLIENT_ID,

0 commit comments

Comments
 (0)