-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[Feat]: Allow turning rewrites off or give better rewrites control over asExternalUri #6504
Comments
tldr Also, sorry for the long delay in a response, I have been out the past few weeks.
Weird, that does seem like it should work. I would have to experiment more with the Dart Code extension. Based on this and some of the other information it sounds like it might be doing some odd things or has some odd expectations, at least when running in the web, but it could also be code-server improperly implementing
I see, yeah if the protocol is already included we should avoid prepending, or strip it out first, or at the very least return an error saying to omit the protocol. We currently always prepend Line 605 in 984fb13
I can confirm the same. Definitely a bug. Seems to happen when we try resolving it against the current domain, in case it is relative. code-server/patches/proxy-uri.diff Line 60 in 984fb13
I think maybe what we do here is avoid trying to resolve if it starts with
Ahh yeah if the proxy is disabled we should definitely skip the rewrite. This could mean passing around the disabled value in VS Code but I think what we do instead is in the patch we use code-server/patches/proxy-uri.diff Line 78 in 984fb13
Then in the wrapping code-server code we set
Yeah I think this only disables showing the rewritten URLs automatically in the ports panel, but
You should get the same That said, I think making it blank ( code-server/patches/proxy-uri.diff Lines 115 to 119 in 984fb13
In summary/action items:
|
Actually I am a bit confused why Ah yeah looks like they do in general:
|
Hi! I work on the Dart-Code extension and had some other reports of things not working correctly when using code-server (flutter/devtools#8067). I was looking to see if some of these issues are easy fixes. The issue with DevTools is that that backend server binds to a local port and thinks it is hosting at Does (or could?) the proxy pass through a header to indicate the original/client-side URL for the resource being requested? Eg. when it send a request for Another possible option that may work based on #4563 is using |
Does Flutter support making it relative by any chance? Would it work if code-server was not rewriting the path? We have a separate proxy endpoint If none of that works then it seems very reasonable to add a header indicating the original path. I did some brief searching and did not find a standard but maybe we could call it
|
One problem with the non-rewriting |
I tested that just after posting here and found that it actually does seem to. However there's another bug (in DevTools) we trigger in that mode (which coincidentally has recently been fixed). I will do some more testing with this - I think a relative (I don't think using I'll post back once I've done some proper testing with the fix above and a relative base href. Thanks! |
(just to close off the discussion above, everything seemed to work fine with a relative base href now, so I'm going ahead with that fix and don't believe anything additional is required to fix the Dart DevTools issue) |
What is your suggestion?
Allow controlling how
asExternalUri()
rewrites work beyond current--proxy-domain
capabilities or allow turning them off completely.Why do you want this feature?
Extensions like Dart Code use
asExternalUri
to open a WebView in the editor with their DevTools. In Dart Code's case, it refuses to function unless it's served offhttp://localhost:port
root, and also requires connection to its WebSocket server on another port.I use manual SSH port forwarding for these ports and it used to work about a year ago, but now code-server rewrites these URLs with its own port forwarding, which doesn't work with the extension and I found no way to fix it.
Are there any workarounds to get this functionality today?
<port>.example.com
port forwarding, but it doesn't work with the extension--proxy-domain http://localhost:{{port}}
because it results inhttps://httplocalhost%3Aport
URLs--proxy-domain localhost:{{port}}
VS Code fails to connect to workbench (The workbench failed to connect to the server (Error: Failed to construct 'URL': Invalid URL))CS_DISABLE_PROXY=1 && code-server
and deleting all the existing port forwards doesn't turn the rewrites offremote.forwardOnOpen
andremote.autoForwardPorts
tofalse
doesn't turn the rewrites off.VSCODE_PROXY_URI=http://localhost:{{port}}
environment variable doesn't produce any resultWith
CS_DISABLE_PROXY=1
environment variable,remote.forwardOnOpen
andremote.autoForwardPorts
set tofalse
, when I set a breakpoint on mainThreadWindow.ts:65, I get the following structure:Some implementation details not very related to the problem, but useful to know: When debugging, I get the aforementioned structure twice, first for the DevTools URL, and the similar one for the debug service URL. While the debug service URL is actually a websocket connection, Dart Code uses http protocol to get the
asExternalUri()
and then replaces it with ws, since the method doesn't support ws port forwarding.After the extension receives the mapped url, a webview opens at
https://example.com/DEBUGGER_URL
, dropping the/proxy/9100
part, which I saw mentioned in the docs, though I don't understand how it works. The webview contains onlyNot Found
error.When using subdomain port forwarding, devtools just fail to load because of some bug in them.
When I copy the URL to my browser and manually change
https://example.com
tohttp://localhost:<port>
(in both URI itself and its URI parameter that contains the endpoint for the debug service), the DevTools load and successfully connect to the websocket port I SSH forwarded earlier.When opening VS Code with port forwarding over
http://localhost:8080
, I get the following structures fromasExternalUri
:Which is exactly what I need. But the resulting webview still points to
localhost:8080
, so the URL gets patched on some stage, but I can't find any lines in Dart Code which would cause that. Unless I'm missing something, my suspicion is that code-server replaces the result somewhere on returning the result to the extension or displaying the webview, but I don't know how to debug the remote side of the extension and need help with that.The extension also has "Launch DevTools in browser" option, which tries to open
https://example.com/proxy/<port>/
when opening VS Code fromexample.com
, andhttp://localhost:8080/proxy/<port>/
when opened from localhost. If I studied the extension's code correctly, it uses openExternal() method.Thus my suggested solution is to either allow to specify any sort of origin template in
--proxy-domain
, likehttp://localhost:{{port}}
, or at least allow rewrites to be turned off so the localhost URIs remain untouched.Are you interested in submitting a PR for this?
I could try, but I'm not familiar with code-server's code base yet.
The text was updated successfully, but these errors were encountered: