Skip to content

Commit

Permalink
ecr-viewer: set url.hostname to x-forwarded-host (#2630)
Browse files Browse the repository at this point in the history
* set url.hostname to x-forwarded-host

* add log statements
  • Loading branch information
BobanL authored Sep 26, 2024
1 parent 951a097 commit 8ed3009
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion containers/ecr-viewer/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ export const config = {
* "auth" parameter does not exist in the request.
*/
function set_auth_cookie(req: NextRequest) {
const url = req.nextUrl;
const url = req.nextUrl.clone();
const auth = url.searchParams.get("auth");
console.log(url);
console.log("==========");
console.log(req);
console.log("------");
if (auth) {
url.searchParams.delete("auth");
url.hostname = req.headers.get("x-forwarded-host") ?? url.hostname;
const response = NextResponse.redirect(url);
response.cookies.set("auth-token", auth, { httpOnly: true });
return response;
Expand Down

0 comments on commit 8ed3009

Please sign in to comment.