From 9295f9fa9da5288dd8a4bf4daef622bb6ff01cc9 Mon Sep 17 00:00:00 2001 From: NguyenND Date: Sun, 28 Jun 2026 18:33:14 -0400 Subject: [PATCH] Jun 28 - Fix bill.stripe.com returns incorrectly --- app/billing/routes.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/billing/routes.py b/app/billing/routes.py index 75d10ec..d4f7a2d 100644 --- a/app/billing/routes.py +++ b/app/billing/routes.py @@ -105,7 +105,8 @@ def subscribe(): price_id = plan.stripe_price_id # Create Checkout Session AFTER the control_session commits customer_id. - base_url = (current_app.config.get('APP_BASE_URL') or request.host_url).rstrip('/') + # Use request.host_url so success/cancel redirect back to the tenant's domain. + base_url = request.host_url.rstrip('/') try: session = create_checkout_session( customer_id=stripe_customer_id, @@ -147,7 +148,9 @@ def portal(): return redirect(url_for('tenant_settings.plan')) stripe_customer_id = t.stripe_customer_id - base_url = (current_app.config.get('APP_BASE_URL') or request.host_url).rstrip('/') + # Use the actual request host so the return URL matches the tenant's domain, + # not the global APP_BASE_URL which points to the primary domain. + base_url = request.host_url.rstrip('/') return_url = f'{base_url}/settings/plan' try: