Skip to content

Commit 9ed53ca

Browse files
committed
TW-1733 Remove setting headers for forwarded responses
1 parent d972aad commit 9ed53ca

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/routers/google-drive.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import axios, { AxiosRequestHeaders, AxiosResponse, AxiosResponseHeaders } from 'axios';
1+
import axios, { AxiosRequestHeaders, AxiosResponse } from 'axios';
22
import { Router } from 'express';
33
import { IncomingHttpHeaders } from 'http';
44
import { omit } from 'lodash';
@@ -40,15 +40,6 @@ const toAxiosRequestHeaders = (headers: IncomingHttpHeaders): AxiosRequestHeader
4040
return axiosHeaders;
4141
};
4242

43-
const fromAxiosResponseHeaders = (headers: AxiosResponseHeaders): Headers => {
44-
const responseHeaders = new Headers();
45-
for (const key in headers) {
46-
responseHeaders.append(key, headers[key]);
47-
}
48-
49-
return responseHeaders;
50-
};
51-
5243
const wrappedBodySchema = objectSchema({
5344
body: mixedSchema(),
5445
contentType: stringSchema().required()
@@ -82,7 +73,8 @@ googleDriveRouter.use(async (req, res) => {
8273
throw new NotAllowedMethodError('Method Not Allowed');
8374
}
8475

85-
res.status(response.status).setHeaders(fromAxiosResponseHeaders(response.headers)).send(response.data);
76+
// TODO: add setting headers to response if needed
77+
res.status(response.status).send(response.data);
8678
} catch (error) {
8779
logger.error('Google Drive API error', error);
8880

@@ -91,10 +83,8 @@ googleDriveRouter.use(async (req, res) => {
9183
}
9284

9385
if (axios.isAxiosError(error) && error.response) {
94-
res
95-
.status(error.response.status)
96-
.setHeaders(fromAxiosResponseHeaders(error.response.headers))
97-
.send(error.response.data);
86+
// TODO: add setting headers to response if needed
87+
res.status(error.response.status).send(error.response.data);
9888
} else {
9989
res.status(500).json({ error: 'Internal Server Error' });
10090
}

0 commit comments

Comments
 (0)