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,
|
HttpStatus,
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
||||||
import { UserRole } from '@prisma/client';
|
import { UserRole } from '@prisma/client';
|
||||||
import { StripeService } from './stripe.service';
|
import { StripeService } from './stripe.service';
|
||||||
@@ -25,6 +26,7 @@ export class StripeController {
|
|||||||
constructor(
|
constructor(
|
||||||
private stripeService: StripeService,
|
private stripeService: StripeService,
|
||||||
private subscriptionService: SubscriptionService,
|
private subscriptionService: SubscriptionService,
|
||||||
|
private configService: ConfigService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
// ---- Public Endpoints ----
|
// ---- Public Endpoints ----
|
||||||
@@ -46,7 +48,7 @@ export class StripeController {
|
|||||||
@CurrentUser() user: any,
|
@CurrentUser() user: any,
|
||||||
@Body() dto: CreateCheckoutDto,
|
@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 successUrl = dto.successUrl || `${frontendUrl}/agent/settings/billings/confirmation`;
|
||||||
const cancelUrl = dto.cancelUrl || `${frontendUrl}/agent/settings/billings`;
|
const cancelUrl = dto.cancelUrl || `${frontendUrl}/agent/settings/billings`;
|
||||||
|
|
||||||
@@ -71,7 +73,7 @@ export class StripeController {
|
|||||||
throw new BadRequestException('No active subscription found');
|
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(
|
return this.stripeService.createBillingPortalSession(
|
||||||
subscription.stripeCustomerId,
|
subscription.stripeCustomerId,
|
||||||
returnUrl,
|
returnUrl,
|
||||||
|
|||||||
Reference in New Issue
Block a user