feat: remove api metadata decorating html responses

This commit is contained in:
Karol Sójko 2022-06-28 14:10:40 +02:00
parent 7c271be310
commit 3035cbc5de
No known key found for this signature in database
GPG key ID: A50543BF560BDEB0

View file

@ -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',