nainglinnkhant
nainglinnkhant
BABetter Auth
Created by nainglinnkhant on 2/18/2025 in #help
OAuth Proxy plugin not working
GitHub config: Homepage URL - https://app.website.com Authorization callback URL - https://app.website.com/api/auth/callback/github
3 replies
BABetter Auth
Created by nainglinnkhant on 2/13/2025 in #help
Can I share client API routes across subdomains?
I see, thanks for your time! 🙌
15 replies
BABetter Auth
Created by nainglinnkhant on 2/13/2025 in #help
Can I share client API routes across subdomains?
yes, my plan is to use one app's auth routes from another app
15 replies
BABetter Auth
Created by nainglinnkhant on 2/13/2025 in #help
Can I share client API routes across subdomains?
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
usePlural: true,
}),
user: {
changeEmail: {
enabled: true,
sendChangeEmailVerification,
},
},
advanced: {
generateId: false,
},
trustedOrigins: [env.NEXT_PUBLIC_WEB_URL, env.NEXT_PUBLIC_ADMIN_URL],
socialProviders: {
google: {
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
},
github: {
clientId: env.GITHUB_CLIENT_ID,
clientSecret: env.GITHUB_CLIENT_SECRET,
},
},
databaseHooks: {
user: {
create: {
after: afterUserCreated,
},
},
session: {
create: {
before: beforeSessionCreated,
},
},
},
plugins: [
nextCookies(),
organization({
sendInvitationEmail,
}),
admin(),
magicLink({
sendMagicLink,
}),
oAuthProxy(),
customSession(customizeSession),
],
});
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
usePlural: true,
}),
user: {
changeEmail: {
enabled: true,
sendChangeEmailVerification,
},
},
advanced: {
generateId: false,
},
trustedOrigins: [env.NEXT_PUBLIC_WEB_URL, env.NEXT_PUBLIC_ADMIN_URL],
socialProviders: {
google: {
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
},
github: {
clientId: env.GITHUB_CLIENT_ID,
clientSecret: env.GITHUB_CLIENT_SECRET,
},
},
databaseHooks: {
user: {
create: {
after: afterUserCreated,
},
},
session: {
create: {
before: beforeSessionCreated,
},
},
},
plugins: [
nextCookies(),
organization({
sendInvitationEmail,
}),
admin(),
magicLink({
sendMagicLink,
}),
oAuthProxy(),
customSession(customizeSession),
],
});
my auth server config already has trustedOrigins configured
15 replies
BABetter Auth
Created by nainglinnkhant on 2/13/2025 in #help
Can I share client API routes across subdomains?
@bekacru It worked after manually modifying the header of GET and POST route handlers. But for social sign-ins, it still redirects to the original baseURL (for example, I call the localhost:3001's API route from localhost:3002 and after sign-in is successful, it redirects to the localhost:3001 instead of localhost:3002). I get that it's the expected behavior. But is there any way to change it? I tried setting callbackURL like below but doesn't work.
await signIn.social({
provider: "github",
callbackURL: "http://localhost:3002",
});
await signIn.social({
provider: "github",
callbackURL: "http://localhost:3002",
});
15 replies
BABetter Auth
Created by nainglinnkhant on 2/13/2025 in #help
Can I share client API routes across subdomains?
I'm using nextjs 15
15 replies
BABetter Auth
Created by nainglinnkhant on 2/13/2025 in #help
Can I share client API routes across subdomains?
you mean crossSubDomainCookies? If you mean other cors config, could you please tell me how to configure?
15 replies
BABetter Auth
Created by nainglinnkhant on 2/13/2025 in #help
Can I share client API routes across subdomains?
@bekacru could you please check this? : )
15 replies
BABetter Auth
Created by nainglinnkhant on 2/13/2025 in #help
Can I share client API routes across subdomains?
When I remove no-cors, I get the cors error as below:
Access to fetch at 'http://localhost:3001/api/auth/sign-in/social' from origin 'http://localhost:3002' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Access to fetch at 'http://localhost:3001/api/auth/sign-in/social' from origin 'http://localhost:3002' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
My server config is as below. Do I need to add or change anything to make it work?
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
usePlural: true,
}),
user: {
changeEmail: {
enabled: true,
sendChangeEmailVerification,
},
},
advanced: {
generateId: false,
},
trustedOrigins: [env.NEXT_PUBLIC_WEB_URL, env.NEXT_PUBLIC_ADMIN_URL],
socialProviders: {
google: {
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
},
github: {
clientId: env.GITHUB_CLIENT_ID,
clientSecret: env.GITHUB_CLIENT_SECRET,
},
},
databaseHooks: {
user: {
create: {
after: afterUserCreated,
},
},
session: {
create: {
before: beforeSessionCreated,
},
},
},
plugins: [
nextCookies(),
organization({
sendInvitationEmail,
}),
admin(),
magicLink({
sendMagicLink,
}),
oAuthProxy(),
customSession(customizeSession),
],
});
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
usePlural: true,
}),
user: {
changeEmail: {
enabled: true,
sendChangeEmailVerification,
},
},
advanced: {
generateId: false,
},
trustedOrigins: [env.NEXT_PUBLIC_WEB_URL, env.NEXT_PUBLIC_ADMIN_URL],
socialProviders: {
google: {
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
},
github: {
clientId: env.GITHUB_CLIENT_ID,
clientSecret: env.GITHUB_CLIENT_SECRET,
},
},
databaseHooks: {
user: {
create: {
after: afterUserCreated,
},
},
session: {
create: {
before: beforeSessionCreated,
},
},
},
plugins: [
nextCookies(),
organization({
sendInvitationEmail,
}),
admin(),
magicLink({
sendMagicLink,
}),
oAuthProxy(),
customSession(customizeSession),
],
});
15 replies
BABetter Auth
Created by nainglinnkhant on 2/12/2025 in #help
Social login on server
No description
7 replies
BABetter Auth
Created by nainglinnkhant on 2/12/2025 in #help
Social login on server
Yea, it's still returning invalid url. The provider is github.
7 replies
BABetter Auth
Created by nainglinnkhant on 2/12/2025 in #help
Social login on server
I tried with "/" and "/dashboard" too. But didn't work.
7 replies