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

feat: update how request.url is derived #506

Closed
wants to merge 4 commits into from

Conversation

mcansh
Copy link
Owner

@mcansh mcansh commented Mar 26, 2025

mcansh added 2 commits March 26, 2025 17:39
Signed-off-by: Logan McAnsh <[email protected]>
Signed-off-by: Logan McAnsh <[email protected]>
@mcansh mcansh requested a review from Copilot March 26, 2025 21:42
Copy link

changeset-bot bot commented Mar 26, 2025

⚠️ No Changeset found

Latest commit: bbf873c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates how the request URL is derived by introducing a port-resolution logic that considers the "X-Forwarded-Host" and "Host" headers and updates the URL construction accordingly.

  • Updated URL derivation logic to include port extraction
  • Modified URL construction using the new port information
  • Added tests to validate the correct parsing of the URL and port

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/remix-fastify/src/shared.ts Updated URL construction to resolve the port from headers
packages/remix-fastify/tests/server.test.ts Added test to validate correct URL formation when a port is provided

Comment on lines 68 to 71
// req.hostname doesn't include port information so grab that from
// `X-Forwarded-Host` or `Host`
let [, hostnamePortStr] = req.get("X-Forwarded-Host")?.split(":") ?? [];
let [, hostPortStr] = req.get("host")?.split(":") ?? [];
Copy link
Preview

Copilot AI Mar 26, 2025

Choose a reason for hiding this comment

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

The variable 'req' is used instead of the function parameter 'request'. Use 'request.get(...)' to maintain consistency with the function signature.

Suggested change
// req.hostname doesn't include port information so grab that from
// `X-Forwarded-Host` or `Host`
let [, hostnamePortStr] = req.get("X-Forwarded-Host")?.split(":") ?? [];
let [, hostPortStr] = req.get("host")?.split(":") ?? [];
// request.hostname doesn't include port information so grab that from
// `X-Forwarded-Host` or `Host`
let [, hostnamePortStr] = request.get("X-Forwarded-Host")?.split(":") ?? [];
let [, hostPortStr] = request.get("host")?.split(":") ?? [];

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

mcansh added 2 commits March 26, 2025 17:45
Signed-off-by: Logan McAnsh <[email protected]>
Signed-off-by: Logan McAnsh <[email protected]>
@mcansh mcansh closed this Mar 26, 2025
@mcansh mcansh deleted the logan/forwarded-host-parse branch March 26, 2025 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant