Skip to content

Commit ac7f843

Browse files
fix: update environment variable handling for CUSTOM_DOMAIN and INGRESS_BASE_DOMAIN
1 parent 11b6803 commit ac7f843

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

api/src/config/env.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ const env = {
6464
SMTP_USER: process.env.SMTP_USER,
6565
SMTP_PASS: process.env.SMTP_PASS,
6666
SMTP_FROM: process.env.SMTP_FROM,
67-
CUSTOM_DOMAIN: process.env.CUSTOM_DOMAIN || "kargo.upayan.dev",
67+
CUSTOM_DOMAIN: process.env.CUSTOM_DOMAIN,
6868

6969
// Ingress domains
70-
INGRESS_BASE_DOMAIN: process.env.INGRESS_BASE_DOMAIN || "vitians.in",
70+
INGRESS_BASE_DOMAIN: process.env.INGRESS_BASE_DOMAIN,
7171

7272
// Directory for manifests
7373
MANIFESTS_DIR: process.env.MANIFESTS_DIR,

api/src/controllers/auth/register.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const register = async (req: Request, res: Response, next: NextFunction) => {
8080
await sendVerificationEmail({
8181
to: email,
8282
token: verificationToken,
83-
domain: env.CUSTOM_DOMAIN,
83+
domain: env.CUSTOM_DOMAIN || req.headers.origin || "",
8484
name,
8585
});
8686

api/src/controllers/auth/resendVerification.controller.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ const resendVerification = async (req: Request, res: Response) => {
4545
user.verificationToken = token;
4646
await user.save();
4747

48+
if (!env.CUSTOM_DOMAIN) {
49+
log({
50+
type: "error",
51+
message: "CUSTOM_DOMAIN is not set in environment variables.",
52+
});
53+
return res
54+
.status(500)
55+
.json(
56+
formatNotification(
57+
"Server configuration error. Please contact support.",
58+
"error"
59+
)
60+
);
61+
}
62+
4863
await sendVerificationEmail({
4964
to: user.email,
5065
token,

api/src/utils/k8s/helpers/k8sHelpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export function getResourceName(type: string, appName: string) {
1818

1919
export const getBaseDomain = () => {
2020
let domain = env.INGRESS_BASE_DOMAIN;
21-
if (domain.startsWith(".")) domain = domain.slice(1);
21+
if (typeof domain === "string" && domain.startsWith("."))
22+
domain = domain.slice(1);
2223
return domain;
2324
};
2425

0 commit comments

Comments
 (0)