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

Commit

Permalink
Remove multiValueHeaders-workaround for preview mode
Browse files Browse the repository at this point in the history
In preview mode (using netlify dev), Netlify Functions now receive
requests as multiValueHeaders and multiValueQueryStrings. Previously,
we needed to manually convert the request to those formats. This now
happens automatically.
  • Loading branch information
FinnWoelm committed Sep 5, 2020
1 parent 1de3719 commit c4b9852
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ I recommend you still use `next dev` to build and preview your application local

But if you want to emulate the Netlify deployment on your computer, you can also run `next-on-netlify` locally and then use `netlify-cli` to preview the result.

First, install the latest version of `netlify-cli` (you can also [look at package.json](https://github.com/netlify/next-on-netlify/blob/master/package.json) to see the version against which next-on-netlify has been tested):
First, install the latest version of `netlify-cli` (you can also [look at package.json](https://github.com/netlify/next-on-netlify/blob/master/package.json) to see the version that next-on-netlify has been tested against):

```bash
npm install -g netlify-cli
Expand Down
18 changes: 0 additions & 18 deletions lib/netlifyFunctionTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,6 @@ const callbackHandler = (callback) =>
};

exports.handler = (event, context, callback) => {
// In netlify dev, we currently do not receive headers as multi value headers.
// So we manually set them from the plain headers. This should become
// redundant as soon as https://github.com/netlify/cli/pull/938 is published.
if (!event.hasOwnProperty("multiValueHeaders")) {
event.multiValueHeaders = {};
Object.keys(event.headers).forEach((key) => {
event.multiValueHeaders[key] = [event.headers[key]];
});
}

// In netlify dev, we currently do not receive query string as multi value
// query string. So we manually set it from the plain query string. This
// should become redundant as soon as https://github.com/netlify/cli/pull/938
//is published.
if (!event.hasOwnProperty("multiValueQueryStringParameters")) {
event.multiValueQueryStringParameters = event.queryStringParameters;
}

// Enable support for base64 encoding.
// This is used by next-aws-lambda to determine whether to encode the response
// body as base64.
Expand Down

0 comments on commit c4b9852

Please sign in to comment.