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: