From c4b985203551535883fa9fb5eb3ea691bce49004 Mon Sep 17 00:00:00 2001 From: Finn Woelm Date: Sat, 5 Sep 2020 21:45:08 +0200 Subject: [PATCH] Remove multiValueHeaders-workaround for preview mode 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. --- README.md | 2 +- lib/netlifyFunctionTemplate.js | 18 ------------------ 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/README.md b/README.md index 04622cd..5770b8f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/netlifyFunctionTemplate.js b/lib/netlifyFunctionTemplate.js index ab074ab..15a7da8 100644 --- a/lib/netlifyFunctionTemplate.js +++ b/lib/netlifyFunctionTemplate.js @@ -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.