fix(serve-sim): Preserve host for exec-ws SSE streams#93
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough
ChangesHost Header Forwarding in exec-ws SSE Proxy
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/serve-sim/src/exec-ws.ts`:
- Around line 220-224: The forwardHost assignment at line 220 only handles
array-valued Host headers but doesn't normalize comma-separated Host strings
like "minipro24.lan:3462, 127.0.0.1:3462". Modify the forwardHost assignment to
first split the Host header by comma and take the first element (trimmed) before
checking if it's an array or string, ensuring that comma-separated Host values
are properly normalized before being used in the split operation at line 223 for
port extraction and preventing NaN values when localPort is unavailable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 0ffce813-12fb-4cdf-a0e6-a78851730468
📒 Files selected for processing (2)
packages/serve-sim/src/__tests__/exec-ws.test.tspackages/serve-sim/src/exec-ws.ts
bf871a9 to
4fde2ed
Compare
Summary
Closes #92.
Preserve the viewer's
Hostheader when/exec-wsproxies allowed SSE subscriptions back through the local serve-sim server.Problem and Fix
minipro24.lan, but/exec-wsproxies/api/eventsthrough a loopbackhttpRequestwithout the originalHostheader./api/eventsthen sees127.0.0.1and publishes loopback helper URLs.Hostheader and forward it on the internal SSE loopback request./exec-wsand asserts LAN preview configs use the LAN hostname while loopback preview configs remain on127.0.0.1.Defensive Fixes
Hostvalues.Validation
bun test packages/serve-sim/src/__tests__/exec-ws.test.tsbun run typecheckbun run lintgit diff --checkbun test packages/serve-sim/src/__tests__/Summary by CodeRabbit
Hostheaders during WebSocket upgrades and related SSE loopback subscriptions, including support for comma-separatedHostvalues, so preview configuration URLs are consistently rewritten for LAN and loopback connections.