Skip to content

Commit 51ac213

Browse files
authored
Merge pull request #764 from trycompai/mariano/comp-123-fix-dev-email-invite
[dev] [Marfuen] mariano/comp-123-fix-dev-email-invite
2 parents ca2e00b + 107113e commit 51ac213

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

apps/app/src/utils/auth.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,28 @@ export const auth = betterAuth({
4141
"https://dev.trycomp.ai",
4242
],
4343
advanced: {
44-
database: {
45-
// This will enable us to fall back to DB for ID generation.
46-
// It's important so we can use custom IDs specified in Prisma Schema.
47-
generateId: false,
48-
},
44+
database: {
45+
// This will enable us to fall back to DB for ID generation.
46+
// It's important so we can use custom IDs specified in Prisma Schema.
47+
generateId: false,
48+
},
4949
},
5050
secret: process.env.AUTH_SECRET!,
5151
plugins: [
5252
organization({
5353
async sendInvitationEmail(data) {
5454
const isLocalhost = process.env.NODE_ENV === "development";
5555
const protocol = isLocalhost ? "http" : "https";
56-
const domain = isLocalhost
57-
? "localhost:3000"
58-
: "app.trycomp.ai";
56+
57+
const betterAuthUrl = process.env.BETTER_AUTH_URL;
58+
const isDevEnv = betterAuthUrl?.includes("dev.trycomp.ai");
59+
const isProdEnv = betterAuthUrl?.includes("app.trycomp.ai");
60+
61+
const domain = isDevEnv
62+
? "dev.trycomp.ai"
63+
: isProdEnv
64+
? "app.trycomp.ai"
65+
: "localhost:3000";
5966
const inviteLink = `${protocol}://${domain}/auth?inviteCode=${data.invitation.id}`;
6067

6168
await sendInviteMemberEmail({

0 commit comments

Comments
 (0)