Skip to content

Commit d62d3a6

Browse files
committed
send data to requestor
1 parent f1f64de commit d62d3a6

File tree

1 file changed

+1
-50
lines changed

1 file changed

+1
-50
lines changed

src/lambda_api/application.ts

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ async function handleEndpoint(req: Request, res: Response, endpoint: string) {
6262
if (response.status === 204) {
6363
res.status(204).end();
6464
} else {
65-
response = removeSomeHeaders(response, true);
66-
if (response.headers) res.set(response.headers);
67-
if (response.type) res.type(response.type);
68-
if (response.cache) res.set("Cache-Control", response.cache);
69-
res.status(response.status).json(response);
65+
res.status(response.status).send(response.data);
7066
}
7167
} catch (error: any) {
7268
console.error(`Error handling ${endpoint} request:`, error);
@@ -101,48 +97,3 @@ function logRequests(request: Request): boolean {
10197

10298
return true;
10399
}
104-
105-
// we dont want certain headers from the backend being sent to the requestor.
106-
function removeSomeHeaders(response: any, all: boolean) {
107-
const headersToRemove = [
108-
"accept",
109-
"accept-language",
110-
"accept-encoding",
111-
"access-control-allow-origin",
112-
"cache-control",
113-
"host",
114-
"connection",
115-
"pragma",
116-
"sec-fetch-dest",
117-
"sec-fetch-mode",
118-
"sec-fetch-site",
119-
"sec-ch-ua",
120-
"sec-ch-ua-mobile",
121-
"sec-ch-ua-platform",
122-
"user-agent",
123-
"upgrade-insecure-requests",
124-
"x-forwarded-for",
125-
"x-forwarded-proto",
126-
"x-forwarded-port",
127-
"x-amzn-trace-id",
128-
"x-amzn-requestid",
129-
"x-amzn-remapped-content-length",
130-
"x-amz-apigw-id",
131-
"x-powered-by",
132-
"x-cache",
133-
"x-amz-cf-pop",
134-
"x-amz-cf-id",
135-
];
136-
137-
if (all) {
138-
delete response.headers;
139-
} else {
140-
headersToRemove.forEach((header) => {
141-
if (response.headers?.[header]) {
142-
delete response.headers[header];
143-
}
144-
});
145-
}
146-
147-
return response;
148-
}

0 commit comments

Comments
 (0)