#Catch an exception from AuthGuard in a specific controller and redirect instead of throw 403.

2 messages · Page 1 of 1 (latest)

manic citrus
#

Hello,

have a controller like this:


  @UseGuards(AuthGuard('jwt'))
  @Get('/checkout')
  async createCheckout(
    @Res() response: Response,
    @Request() req,
    @Query() paymentRequestBody: PaymentRequestDTO,
  ) {
    const checkout = await this.paymentService.createCheckout(
      req.user,
      paymentRequestBody,
    )

    return response.redirect(HttpStatus.SEE_OTHER, checkout.url)
  }

trying to figure out how to catch HttpException(403) from Authguard and redirect , but only for this controller.

fallen solar
#

You could make a specific filter for it