fix: forward browser headers in WebSocket upgrade handshake#62
Open
abdushakurob wants to merge 1 commit into
Open
fix: forward browser headers in WebSocket upgrade handshake#62abdushakurob wants to merge 1 commit into
abdushakurob wants to merge 1 commit into
Conversation
|
@abdushakurob is attempting to deploy a commit to the Akinkunmi Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #61
Polling worked through the tunnel but WebSocket upgrades failed. The
backend never saw the handshake. The problem was in the local ws dialer:
when the CLI opens the matching ws://localhost connection to the backend,
it was only forwarding a minimal header set and passing
Sec-WebSocket-Protocol incorrectly as a plain header instead of through
the ws constructor's subprotocol argument.
Socket.IO's upgrade handshake is stricter than a bare WebSocket server
about headers like Origin, which is why this surfaced there specifically
while plain WebSocket backends tolerated it fine.
Changes
referer, user-agent) from the tunnel edge into the local ws dialer
instead of setting Sec-WebSocket-Protocol as a plain header
all incoming headers including hop-by-hop ones
Testing
Added
packages/core/src/client.ws-upgrade.test.tsto prevent thisregression from coming back. It checks two things: that the tunnel client
can forward a WebSocket upgrade to a plain WebSocket backend, and that it
preserves the headers Socket.IO cares about, especially Origin, so a
Socket.IO server can accept the upgrade instead of staying stuck on
polling or timing out.
In short, the test proves the tunnel is replaying the browser's upgrade
context correctly, not just opening a socket.
Both cases pass locally. Also built core, CLI, and tunnel packages,
all clean.