diff --git a/lib/templates/netlifyFunction.js b/lib/templates/netlifyFunction.js index 15a7da8..222c0d9 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"; } + // x-forwarded-host is undefined on Netlify for proxied apps that need it + // fixes https://github.com/netlify/next-on-netlify/issues/46 + if (!event.multiValueHeaders.hasOwnProperty("x-forwarded-host")) { + event.multiValueHeaders["x-forwarded-host"] = [event.headers["host"]]; + } + // Get the request URL const { path } = event; console.log("[request]", path);