Skip to content

The open alternative to Salesforce, designed for AI.

Fix wrong domainName for redirect url (#9586)

martmull55bae60f6963
diff --git a/packages/twenty-server/src/engine/core-modules/billing/billing.resolver.ts b/packages/twenty-server/src/engine/core-modules/billing/billing.resolver.ts
index 5109c1ffeca..34d55e27769 100644
--- a/packages/twenty-server/src/engine/core-modules/billing/billing.resolver.ts
+++ b/packages/twenty-server/src/engine/core-modules/billing/billing.resolver.ts
@@ -45,7 +45,7 @@ export class BillingResolver {
) {
return {
url: await this.billingPortalWorkspaceService.computeBillingPortalSessionURLOrThrow(
- workspace.id,
+ workspace,
returnUrlPath,
),
};
diff --git a/packages/twenty-server/src/engine/core-modules/billing/services/billing-portal.workspace-service.ts b/packages/twenty-server/src/engine/core-modules/billing/services/billing-portal.workspace-service.ts
index 788f2bf6e9c..8966793643c 100644
--- a/packages/twenty-server/src/engine/core-modules/billing/services/billing-portal.workspace-service.ts
+++ b/packages/twenty-server/src/engine/core-modules/billing/services/billing-portal.workspace-service.ts
@@ -36,7 +36,9 @@ export class BillingPortalWorkspaceService {
plan?: BillingPlanKey,
requirePaymentMethod?: boolean,
): Promise<string> {
- const frontBaseUrl = this.domainManagerService.getBaseUrl();
+ const frontBaseUrl = this.domainManagerService.buildWorkspaceURL({
+ subdomain: workspace.subdomain,
+ });
const cancelUrl = frontBaseUrl.toString();
if (successUrlPath) {
@@ -72,13 +74,13 @@ export class BillingPortalWorkspaceService {
}
async computeBillingPortalSessionURLOrThrow(
- workspaceId: string,
+ workspace: Workspace,
returnUrlPath?: string,
) {
const currentSubscription =
await this.billingSubscriptionService.getCurrentBillingSubscriptionOrThrow(
{
- workspaceId,
+ workspaceId: workspace.id,
},
);
@@ -92,7 +94,9 @@ export class BillingPortalWorkspaceService {
throw new Error('Error: missing stripeCustomerId');
}
- const frontBaseUrl = this.domainManagerService.getBaseUrl();
+ const frontBaseUrl = this.domainManagerService.buildWorkspaceURL({
+ subdomain: workspace.subdomain,
+ });
if (returnUrlPath) {
frontBaseUrl.pathname = returnUrlPath;