diff --git a/packages/api-gateway/src/Service/Http/HttpService.ts b/packages/api-gateway/src/Service/Http/HttpService.ts index 32591fb39..b4b641c08 100644 --- a/packages/api-gateway/src/Service/Http/HttpService.ts +++ b/packages/api-gateway/src/Service/Http/HttpService.ts @@ -162,6 +162,12 @@ export class HttpService implements HttpServiceInterface { this.applyResponseHeaders(serviceResponse, response) + if (this.responseShouldNotBeDecorated(serviceResponse)) { + response.status(serviceResponse.status).send(serviceResponse.data) + + return + } + response.status(serviceResponse.status).send({ meta: { auth: { @@ -213,6 +219,10 @@ export class HttpService implements HttpServiceInterface { return payload } + private responseShouldNotBeDecorated(serviceResponse: AxiosResponse): boolean { + return serviceResponse.headers['content-type'].toLowerCase().includes('text/html') + } + private applyResponseHeaders(serviceResponse: AxiosResponse, response: Response): void { const returnedHeadersFromUnderlyingService = [ 'access-control-allow-methods',