-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Make live-reload (HMR) work out-of-the-box by directly exposing ports on the workspace URL #3282
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
Comments
Yeah, this might be a duplicate of #3184 The key difference is that one is explicitly about generic tcp port exposure, and this one could be handled with http proxy it appears. |
Hmm, the issues definitely seem related, but to me they're not quite the same:
Then, SSH access will probably require a directly-exposed port too (#1781) and there have been a few requests for other non-HTTP ports to be exposed (e.g. MySQL: #736), which are probably all TCP-based. |
What about having a domain such as ssl-.gitpod.io: for the HTTPS-proxied version and .gitpod.io: for TCP |
💭 Thought: The Local Companion app might make many localhost-assuming workflows just work out-of-the-box as well (e.g. HMR / live-reload), since you will be developing on your actual |
Yes, it should resolve this issue, I hope to teach VS Code Web to see localhost tunnels 🤞 and given that required ports are available on local machine it should just work. |
We just announced preview version of Gitpod local companion which allows to tunnel any tcp port: https://www.gitpod.io/blog/local-app please try and give us feedback 🙏🏻 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
by now you can use the local app to tunnel localhost and VS Code Web knows about it, you can also use VS Code Desktop. |
Shamelessly stolen from https://raw.githubusercontent.com/PEZ/get-started-with-clojure TODO * Eval cljs fails with: No available JS runtime. See https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting * Not sure how to access Inspector at :9630 Shadow We can use the companion app to enable access via localhost and to any port and protocol - https://www.gitpod.io/blog/local-app (introduced for Live Reload). Currently shadow fails b/c 1) it uses ws instead of wss (and I'm not sure ws(s) supported by G.P.) and because each port has a different host and it tries 8181-<host>:9630 instead of 9630-<host>. Background: gitpod-io/gitpod#3282
Shamelessly stolen from https://raw.githubusercontent.com/PEZ/get-started-with-clojure TODO * Eval cljs fails with: No available JS runtime. See https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting * Not sure how to access Inspector at :9630 Shadow We can use the companion app to enable access via localhost and to any port and protocol - https://www.gitpod.io/blog/local-app (introduced for Live Reload). Currently shadow fails b/c 1) it uses ws instead of wss (and I'm not sure ws(s) supported by G.P.) and because each port has a different host and it tries 8181-<host>:9630 instead of 9630-<host>. Background: gitpod-io/gitpod#3282 According to https://github.com/thheller/shadow-cljs/blob/69abb8e088cce7db7a901d9371225a0b98aa424b/src/main/shadow/cljs/devtools/client/env.cljs#L98-L111 the WS URL is hard-coded in shadow :-(
Shamelessly stolen from https://raw.githubusercontent.com/PEZ/get-started-with-clojure TODO * Eval cljs fails with: No available JS runtime. See https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting * Not sure how to access Inspector at :9630 Shadow We can use the companion app to enable access via localhost and to any port and protocol - https://www.gitpod.io/blog/local-app (introduced for Live Reload). Currently shadow fails b/c 1) it uses ws instead of wss (and I'm not sure ws(s) supported by G.P.) and because each port has a different host and it tries 8181-<host>:9630 instead of 9630-<host>. Background: gitpod-io/gitpod#3282 According to https://github.com/thheller/shadow-cljs/blob/69abb8e088cce7db7a901d9371225a0b98aa424b/src/main/shadow/cljs/devtools/client/env.cljs#L98-L111 the WS URL is hard-coded in shadow :-(
Preamble
When you start an HTTP server in a Gitpod workspace, the port can be exposed to the public internet via a HTTPS proxy.
For example, in a workspace called
red-fox-abcd
, you can:python3 -m http.server 3000
)The Preview tab will have the URL
https://3000-red-fox-abcd:443/
.Problems
The web server might expect to run on
localhost:3000
, but instead it is accessed via a different domain (3000-red-fox-abcd
) and a different port (443
, the default HTTPS port). But usually, the web server can be configured to accept other domains/ports, and to replace all links in the app with correct URLs, for example by:0.0.0.0
instead of127.0.0.1
http://localhost:3000
proxied behindhttps://3000-red-fox-abcd:443
)However, things get worse when the app wants to run a secondary web server (e.g. backend service, DB, API server, live-reload/HMR) on a different port:
3000-red-fox-abcd:3001
instead of3001-red-fox-abcd:443
The fixes there are a bit trickier, or sometimes even impossible. Some workaround we've found to occasionally work are:
3001
while making the front-end use a port that is not3001
)localhost
)sed
after installing it in the workspace: https://github.com/sveltejs/svelte/pull/4277/files#diff-370a022e48cb18faf98122794ffc5ce775b2606b09a9d1f80b71333425ec078eR7Explanation
Probably the core problem here is that Gitpod's proxy behavior is unique and unexpected for most web servers: It encodes the port into the domain, causing a double confusion for web servers (different domain & different port than what's running on
localhost
, or even on the proxied primary web service).Solution
We can simplify setups and remove the need for awkward workarounds by making the Gitpod proxy behavior a little more "standard", i.e. by exposing server ports as actual ports and not as domains:
3000-red-fox-abcd:443
-->red-fox-abcd:3000
3001-red-fox-abcd:443
-->red-fox-abcd:3001
This means only the domain needs to be configured/accepted by web servers, and it's the same domain even for secondary servers (so a framework randomly exposing & accessing different ports will most likely just work out-of-the-box without mad configuration wrangling).
The text was updated successfully, but these errors were encountered: