Skip to content

Commit b83e010

Browse files
committed
fix: ensure Location header is encoded in redirects
1 parent ad701c2 commit b83e010

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/open-next/src/core/routingHandler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ export default async function routingHandler(
9696

9797
const redirect = handleRedirects(internalEvent, RoutesManifest.redirects);
9898
if (redirect) {
99+
// We need to encode query params in the Location header to make sure it is valid according to RFC
100+
// https://stackoverflow.com/a/7654605/16587222
101+
redirect.headers.Location = new URL(
102+
redirect.headers.Location as string,
103+
).href;
99104
debug("redirect", redirect);
100105
return redirect;
101106
}

0 commit comments

Comments
 (0)