Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

Commit e2b65f2

Browse files
committed
Remove workaround: base64 support in Netlify Functions
As far as I know, Netlify Functions always support base64 encoding. So we can remove the code for checking if base64 encoding is supported.
1 parent e7c8641 commit e2b65f2

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

lib/templates/netlifyFunction.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ const callbackHandler = (callback) =>
2626
};
2727

2828
exports.handler = (event, context, callback) => {
29-
// Enable support for base64 encoding.
30-
// This is used by next-aws-lambda to determine whether to encode the response
31-
// body as base64.
32-
if (!process.env.hasOwnProperty("BINARY_SUPPORT")) {
33-
process.env.BINARY_SUPPORT = "yes";
34-
}
35-
3629
// x-forwarded-host is undefined on Netlify for proxied apps that need it
3730
// fixes https://github.com/netlify/next-on-netlify/issues/46
3831
if (!event.multiValueHeaders.hasOwnProperty("x-forwarded-host")) {

lib/templates/reqResMapper.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ const queryString = require("querystring");
77
const http = require("http");
88

99
const reqResMapper = (event, callback) => {
10-
const base64Support = process.env.BINARY_SUPPORT === "yes";
1110
const response = {
12-
isBase64Encoded: base64Support,
11+
isBase64Encoded: true,
1312
multiValueHeaders: {},
1413
};
1514
let responsePromise;
@@ -116,9 +115,7 @@ const reqResMapper = (event, callback) => {
116115
}
117116

118117
if (response.body) {
119-
response.body = Buffer.from(response.body).toString(
120-
base64Support ? "base64" : undefined
121-
);
118+
response.body = Buffer.from(response.body).toString("base64");
122119
}
123120
response.multiValueHeaders = res.headers;
124121
res.writeHead(response.statusCode);

0 commit comments

Comments
 (0)