diff --git a/lib/server.js b/lib/server.js index 90ea981..85cdb55 100644 --- a/lib/server.js +++ b/lib/server.js @@ -212,11 +212,11 @@ function Server(contentDirectory, lambdaApi, logger) { const responseHeaders = cloneDeep(response.headers || {}); Object.keys(responseHeaders).filter(h => h.match(/location/i)).forEach(header => { - responseHeaders[header] = responseHeaders[header].replace(/^https?:\/\/(localhost:\d{2,5})\/(.*)$/g, 'http://$1/api/$2'); + responseHeaders[header] = `${responseHeaders[header]}`.replace(/^https?:\/\/(localhost:\d{2,5})\/(.*)$/g, 'http://$1/api/$2'); }); const multiValueHeaders = cloneDeep(response.multiValueHeaders || {}); Object.keys(multiValueHeaders).filter(h => multiValueHeaders[h]).forEach(h => { - responseHeaders[h] = multiValueHeaders[h].filter(v => v).map(v => v.replace(/^https?:\/\/(localhost:\d{2,5})\/(.*)$/g, 'http://$1/api/$2')); + responseHeaders[h] = multiValueHeaders[h].filter(v => v).map(v => `${v}`.replace(/^https?:\/\/(localhost:\d{2,5})\/(.*)$/g, 'http://$1/api/$2')); }); if (Array.isArray(responseHeaders['Content-Type'])) {