forked from Yara724/api
fix: sms links to match the base url
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user