From 5a88b0ffa6579997fd4f644a5799543284cea481 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Sun, 8 Mar 2026 21:37:01 +0530 Subject: [PATCH] fix: use FRONTEND_URL from config for Stripe redirect URLs instead of hardcoded localhost --- src/stripe/stripe.controller.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stripe/stripe.controller.ts b/src/stripe/stripe.controller.ts index a4dd50c..248f2b1 100644 --- a/src/stripe/stripe.controller.ts +++ b/src/stripe/stripe.controller.ts @@ -10,6 +10,7 @@ import { HttpStatus, BadRequestException, } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; import { UserRole } from '@prisma/client'; import { StripeService } from './stripe.service'; @@ -25,6 +26,7 @@ export class StripeController { constructor( private stripeService: StripeService, private subscriptionService: SubscriptionService, + private configService: ConfigService, ) {} // ---- Public Endpoints ---- @@ -46,7 +48,7 @@ export class StripeController { @CurrentUser() user: any, @Body() dto: CreateCheckoutDto, ) { - const frontendUrl = 'http://localhost:3000'; + const frontendUrl = this.configService.get('app.frontendUrl') || 'http://localhost:3000'; const successUrl = dto.successUrl || `${frontendUrl}/agent/settings/billings/confirmation`; const cancelUrl = dto.cancelUrl || `${frontendUrl}/agent/settings/billings`; @@ -71,7 +73,7 @@ export class StripeController { throw new BadRequestException('No active subscription found'); } - const returnUrl = dto.returnUrl || 'http://localhost:3000/agent/settings/billings'; + const returnUrl = dto.returnUrl || `${this.configService.get('app.frontendUrl') || 'http://localhost:3000'}/agent/settings/billings`; return this.stripeService.createBillingPortalSession( subscription.stripeCustomerId, returnUrl,