diff --git a/apps/api/src/proxy/proxy.controller.ts b/apps/api/src/proxy/proxy.controller.ts index 956c576..4e04bec 100644 --- a/apps/api/src/proxy/proxy.controller.ts +++ b/apps/api/src/proxy/proxy.controller.ts @@ -1,7 +1,15 @@ import { queryTTL } from './lib/config'; import type { GQLRequest } from './types'; import { CACHE_MANAGER } from '@nestjs/cache-manager'; -import { All, Controller, Inject, Req, Res } from '@nestjs/common'; +import { + All, + Controller, + HttpException, + HttpStatus, + Inject, + Req, + Res, +} from '@nestjs/common'; import type { Cache } from 'cache-manager'; import { FastifyReply, FastifyRequest } from 'fastify'; import { env } from 'src/config/env'; @@ -34,6 +42,12 @@ export class ProxyController { method: req.method, }); + if (!response.ok) + throw new HttpException( + response.statusText, + response.status || HttpStatus.INTERNAL_SERVER_ERROR, + ); + const data = await response.json(); const ttl = queryTTL[operationName]; if (data && ttl !== false)