Skip to content

Commit

Permalink
fix: don't delete port if forwarded host is localhost (wevm#254)
Browse files Browse the repository at this point in the history
* fix: don't delete port if forwarded host is localhost

Fixes wevm#253

* chore: changesets
  • Loading branch information
dalechyn committed Apr 14, 2024
1 parent a6aa0b5 commit e38c898
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tasty-spoons-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frog": patch
---

Fixed an issue with local devtools with nextjs template that sets `x-forwarded-host` header to `localhost` which previously deleted the port and ended up creating incorrect link.
2 changes: 1 addition & 1 deletion src/utils/getRequestUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export function getRequestUrl(req: Context['req']) {
const forwardedHost = req.header('x-forwarded-host')
url.host = forwardedHost ?? url.host
url.protocol = req.header('x-forwarded-proto') ?? url.protocol
if (forwardedHost) url.port = ''
if (!forwardedHost?.startsWith('localhost')) url.port = ''
return url
}

0 comments on commit e38c898

Please sign in to comment.