Skip to content

fix(web-outgoing): handle object target in redirect host rewrite#108

Merged
pi0 merged 1 commit intomainfrom
fix/target-object-crash
Mar 25, 2026
Merged

fix(web-outgoing): handle object target in redirect host rewrite#108
pi0 merged 1 commit intomainfrom
fix/target-object-crash

Conversation

@pi0
Copy link
Copy Markdown
Member

@pi0 pi0 commented Mar 25, 2026

Summary

  • Fix crash when options.target is a ProxyTargetDetailed object (not a string or URL) and the setRedirectHostRewrite middleware runs on a redirect response
  • The new URL() constructor was called with a plain object, which throws Invalid URL; now constructs the URL from the object's protocol, host/hostname, and port properties
  • Add regression tests for both object and URL instance targets

Upstream: http-party/node-http-proxy#1600

Test plan

  • Regression test: setRedirectHostRewrite with ProxyTargetDetailed object target
  • Existing test: setRedirectHostRewrite with URL instance target
  • Full test suite passes (230 tests)

When `options.target` is a `ProxyTargetDetailed` object (not a string
or URL), `setRedirectHostRewrite` crashed with `Invalid URL` because
`new URL()` cannot parse a plain object. Construct the URL from the
object's `protocol`, `host`/`hostname`, and `port` properties instead.

Upstream: http-party/node-http-proxy#1600
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 25, 2026

Warning

Rate limit exceeded

@pi0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 21 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c4ef4ca6-c361-495a-b9ce-098045215d54

📥 Commits

Reviewing files that changed from the base of the PR and between 8724245 and 8b2b8ea.

📒 Files selected for processing (2)
  • src/middleware/web-outgoing.ts
  • test/middleware/web-outgoing.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/target-object-crash

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.20%. Comparing base (8724245) to head (8b2b8ea).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #108      +/-   ##
==========================================
+ Coverage   96.14%   96.20%   +0.05%     
==========================================
  Files           8        8              
  Lines         623      632       +9     
  Branches      233      237       +4     
==========================================
+ Hits          599      608       +9     
  Misses         24       24              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pi0 pi0 merged commit 13a5fc7 into main Mar 25, 2026
7 checks passed
@pi0 pi0 deleted the fix/target-object-crash branch March 25, 2026 20:28
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