fix: use FRONTEND_URL from config for Stripe redirect URLs instead of hardcoded localhost
This commit is contained in:
@@ -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<string>('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<string>('app.frontendUrl') || 'http://localhost:3000'}/agent/settings/billings`;
|
||||
return this.stripeService.createBillingPortalSession(
|
||||
subscription.stripeCustomerId,
|
||||
returnUrl,
|
||||
|
||||
Reference in New Issue
Block a user