Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: request url no forwarded host #256

Merged
merged 4 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/modern-baboons-build.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this changeset more concise?

i.e. “Fixed a regression where…”

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frog": patch
---

Fixed a regression in local environment where port was deleted from the generated metadata `postUrl` and `image` tags that resulted in incorrect links when `X-Forwarded-Host` header value is `localhost`.
dalechyn marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 2 additions & 1 deletion src/utils/getRequestUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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?.startsWith('localhost')) url.port = ''
if (forwardedHost !== undefined && !forwardedHost.startsWith('localhost'))
url.port = ''
return url
}
Loading