Skip to content

Commit

Permalink
Ensure all header values are strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitlab Runner committed Aug 12, 2024
1 parent e2edd5a commit c8317a8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down

0 comments on commit c8317a8

Please sign in to comment.