From 9c12e0563298a710398c3e99203f12acca22c73f Mon Sep 17 00:00:00 2001 From: Leonardo Meneguzzi Date: Sun, 20 Sep 2020 20:08:45 -0300 Subject: [PATCH] Copy host property from headers to multiValueHeaders --- lib/netlifyFunctionTemplate.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/netlifyFunctionTemplate.js b/lib/netlifyFunctionTemplate.js index 15a7da8..e10c818 100644 --- a/lib/netlifyFunctionTemplate.js +++ b/lib/netlifyFunctionTemplate.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);