This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proxy websocket connections when using authenticated (realish) preview
Previously, Wrangler would return a "101 Switching Protocols" request and then immediately close the TCP connection. This changes it to instead continue proxying the connection to the remote worker. This is simpler than `wrangler dev --inspect` (and uses a different codepath) because it only proxies the TCP connection directly rather than trying to inspect each websocket message. # How do I use this? 1. Create a worker that uses WebSockets. I used https://github.com/cloudflare/websocket-template with the `protocol` in template.js changed from `wss` to `ws`. 2. Run `wrangler dev http http`. Note that `wrangler dev` (i.e. with the default of `https` for the upstream connection) requires you to first deploy the worker at least once. Without deploying, the remote worker won't receive the `Connection: Upgrade` and `Upgrade: Websocket` headers. Unauthenticated preview is not currently supported.
- Loading branch information
Showing
5 changed files
with
63 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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