I am using a BFF as a proxy.
I need get a excel (and pdf) file from server and forward to download from front app (that are using reactjs).
The code:
monthlyGet(): Observable<AxiosResponse<any>> {
const req: Request = RequestContext.currentContext.req;
const headers = req.headers as AxiosRequestHeaders;
const api = this.configService.get<string>('REPORTS_API');
const path = req.path;
const query = req.url.split('?')[1];
const url = `${api}${path}${query ? `?${query}` : ''}`;
delete headers.host;
return this.httpService
.get(url, { headers })
.pipe(
catchError((e) => {
throw new HttpException(e.response?.data, e.response?.status || 500);
}),
)
.pipe(map((response) => response.data));
}
The result is a corrupted file.
I've tried several ways using stream, buffer... unsuccessfully.