From c41afe5224ec73c8447fbd427468a00b55730956 Mon Sep 17 00:00:00 2001 From: Leonardo Meneguzzi Date: Sun, 20 Sep 2020 20:08:45 -0300 Subject: [PATCH 1/2] Copy host property from headers to multiValueHeaders --- lib/templates/netlifyFunction.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/templates/netlifyFunction.js b/lib/templates/netlifyFunction.js index 15a7da8..e10c818 100644 --- a/lib/templates/netlifyFunction.js +++ b/lib/templates/netlifyFunction.js @@ -31,6 +31,12 @@ exports.handler = (event, context, callback) => { process.env.BINARY_SUPPORT = "yes"; } + // When running at the netlify, the header "host" is not set in + // multiValueHeaders. So we manually set this property. + if(!event.multiValueHeaders.hasOwnProperty('host')) { + event.multiValueHeaders['host'] = [event.headers['host']] + } + // Get the request URL const { path } = event; console.log("[request]", path); From 07f6f299de5debadda8ce738cffb2b2f6c15e66e Mon Sep 17 00:00:00 2001 From: Lindsay Levine Date: Thu, 1 Oct 2020 00:51:20 -0400 Subject: [PATCH 2/2] add TO-DO to remove host property setting after internal fix --- lib/templates/netlifyFunction.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/templates/netlifyFunction.js b/lib/templates/netlifyFunction.js index e10c818..f639ed3 100644 --- a/lib/templates/netlifyFunction.js +++ b/lib/templates/netlifyFunction.js @@ -31,8 +31,9 @@ exports.handler = (event, context, callback) => { process.env.BINARY_SUPPORT = "yes"; } - // When running at the netlify, the header "host" is not set in - // multiValueHeaders. So we manually set this property. + // When running on netlify, the header "host" is not set in + // multiValueHeaders so we manually set it here. + // TO-DO: @lindsaylevine/@cassidoo remove after netlify supports internally if(!event.multiValueHeaders.hasOwnProperty('host')) { event.multiValueHeaders['host'] = [event.headers['host']] }