fix: sms links to match the base url

This commit is contained in:
SepehrYahyaee
2026-11-01 15:37:42 +03:30
parent 9e158d4e8d
commit 6e94717cc8
2 changed files with 138 additions and 2 deletions
@@ -47,10 +47,21 @@ export class SmsOrchestrationService implements OnModuleInit {
const applicationUrl = String(process.env.URL ?? "")
.trim()
.replace(/\/+$/, "");
const userBasePath = String(process.env.USER_BASE_PATH ?? "")
// SMS links must point into the user panel. Keep `user` as the default so
// existing deployments do not silently generate links at `/car-damage/v1/...`
// when USER_BASE_PATH is omitted.
const userBasePath = String(process.env.USER_BASE_PATH ?? "user")
.trim()
.replace(/^\/+|\/+$/g, "");
return userBasePath ? `${applicationUrl}/${userBasePath}` : applicationUrl;
if (!userBasePath) return applicationUrl;
// Some deployments already include the user mount in URL. Avoid adding it
// twice when USER_BASE_PATH is also configured.
const normalizedBasePath = userBasePath.toLowerCase();
const normalizedApplicationUrl = applicationUrl.toLowerCase();
return normalizedApplicationUrl.endsWith(`/${normalizedBasePath}`)
? applicationUrl
: `${applicationUrl}/${userBasePath}`;
}
private buildUserPanelLink(...segments: string[]): string {