Skip to content

Commit

Permalink
Added leading slash to Location URL response (#1411)
Browse files Browse the repository at this point in the history
  • Loading branch information
finnholland authored Dec 2, 2024
1 parent 0e3437c commit 0c37465
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/prerender-fargate/lib/prerender/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 0c37465

Please sign in to comment.