diff --git a/packages/prerender-fargate/lib/prerender/server.js b/packages/prerender-fargate/lib/prerender/server.js index 4e6bd0d4..c0177c29 100644 --- a/packages/prerender-fargate/lib/prerender/server.js +++ b/packages/prerender-fargate/lib/prerender/server.js @@ -238,11 +238,16 @@ server.use({ } let headerMatch = headerMatchRegex.exec(head); - while (headerMatch) { - s3Metadata.location = - headerMatch[1].toLowerCase() == "location" - ? he.decode(headerMatch[2] || headerMatch[4]) - : ""; + while (headerMatch) { + const decoded = he.decode(headerMatch[2] || headerMatch[4]) + if (headerMatch[1].toLowerCase() == "location") { + s3Metadata.location = decoded + if (!decoded.startsWith('http') && !decoded.startsWith('/')) { + s3Metadata.location = '/' + s3Metadata.location + } + } else { + s3Metadata.location = "" + } res.setHeader(headerMatch[1] || headerMatch[3], s3Metadata.location); req.prerender.content = req.prerender.content .toString()