FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Set environment variable VSCODE_PROXY_URI · Issue #1510 · coder/code-server · GitHub

Repository navigation

Set environment variable VSCODE_PROXY_URI #1510

Closed
coder/vscode
#42

Description

With the implementation of the HTTP proxy it would be great to have an environment variable VSCODE_HTTP_REFERER available to build custon URLs for proxied webview requests.

This feature helps solving REditorSupport/vscode-R#275. The existence of such an environment variable also allows to differentiate a local (VS Code) installation from a server (code-server) installation.

Other server-based IDEs set an environment variable based on the HTTP referer when the client session is initialized. See https://github.com/rstudio/rstudio/blob/aa266ded96123f654e5f3163cde39697744eee89/src/cpp/session/SessionClientInit.cpp#L170 for example.

Could you implement something similar in code-server? Or is the information on the HTTP referer already available somewhere else?

Activity

  1. kylecarbs commented on Apr 14, 2020

    Member

    Neat. I don't think we have this ATM.

    Thoughts @code-asher ?

  2. code-asher commented on Apr 15, 2020

    Member

    I experimented with replacing 127.0.0.1:<port> with /proxy/<port> before writing out the webview HTML which worked for the PlatformIO extension but then it tried to make a websocket connection against the root (/wsrpc) instead of being relative (/path/<port>/wsrpc) which obviously won't work.

    So the environment variable sounds like a reasonable way to solve this. Either that or require that extensions be aware that they might be behind a proxied base path and make connections accordingly. There might be other cases I haven't considered though so the environment variable seems like the most flexible.

  3. code-asher commented on Aug 3, 2020

    Member

    We should also make this environment variable available to the terminal (in addition to extensions), see #1939.

  4. added this to the Backlog milestone on Apr 29, 2021
  5. benz0li commented on Jun 13, 2021

    ContributorAuthor

    @code-asher Any timeframe on this issue? Does the name tend towards VSCODE_HTTP_REFERER or CODE_SERVER_HTTP_REFERER?

    The project collaborators at Ikuyadeu/vscode-R might give another go at REditorSupport/vscode-R#275 while working on REditorSupport/vscode-R#358.

  6. code-asher commented on Jun 14, 2021

    Member
  7. code-asher commented on Jun 14, 2021

    Member
  8. benz0li commented on Jun 14, 2021

    ContributorAuthor

    Oh right the name. I think CODE_SERVER_HTTP_REFERER makes sense.

    @code-asher Keeping in mind other derivatives of VS Code (e.g. Eclipse Theia) it would make sense to tend towards VSCODE_HTTP_REFERER.
    👉 The name of their ancestor; a common name to implement the functionality for Ikuyadeu/vscode-R in all of VS Code derivatives - if their collaborators decide to do so.

    Agreed?

  9. benz0li commented on Jun 14, 2021

    ContributorAuthor

    Alternaively HTTP_REFERER; neutral, not mentioning a product name.

  10. code-asher commented on Jun 14, 2021

    Member

    That makes perfect sense to me! My vote would be for HTTP_REFERER I think but I'm good with either one.

  11. benz0li commented on Jun 15, 2021

    ContributorAuthor

    Please use VSCODE_HTTP_REFERER then, as there are already other environment variables in code-server prefixed with VSCODE_ referencing to its ancestor; e.g. VSCODE_GIT_IPC_HANDLE, VSCODE_GIT_ASKPASS_NODE, etc.

    Thank you!

  12. modified the milestones: Backlog, 3.11.0 on Jun 15, 2021
  13. code-asher commented on Jun 15, 2021

    Member

    Should we be using the actual referer header here (or host actually I suppose)? Or do we want the proxy path? If it needs to be general for other editors I'm thinking they might not all have /proxy or might do it differently so maybe we need something like VSCODE_PROXY_URI or something like that, perhaps with {port} in it.

    Then if the user has sub-domain proxies enabled we could set it to {port}.mydomain.com and if they don't we could set it to mydomain.com/proxy/{port}. And if the environment variable already exists we wouldn't override it so users could provide their own proxy through Caddy, NGINX, etc.

    Otherwise we might need to use CODE_SERVER_HTTP_REFERER so extensions can tell the difference between editors and select the URL appropriately.

  14. 26 remaining items

  15. modified the milestones: 3.11.0, 3.12.0 on Jul 19, 2021
  16. added a commit that references this issue on Aug 25, 2021
    e337741
  17. modified the milestones: 3.12.0, 3.12.1 on Sep 9, 2021
  18. benz0li commented on Sep 16, 2021

    ContributorAuthor

    FYI https://vscode-r.jupyter.b-data.ch has been updated:

    • JupyterHub v1.4.2
    • JupyterLab v3.1.14 including
      • code-server v3.12.0 (aka VS Code v1.60.0)
      • Extensions: R v2.3.0
      • ...
  19. jsjoeio commented on Sep 16, 2021

    Contributor

    Just a heads-up - we've had a bunch of other priorities come up and haven't been able to get to this yet (but we will soon)

  20. benz0li commented on Jan 5, 2022

    ContributorAuthor

    @code-asher coder/vscode#37 sets mydomain.com/proxy/{{port}} instead of mydomain.com/proxy/{port}.
    ℹ️ Tested with the latest release artefacts.

    Why the double brackets?

  21. benz0li commented on Jan 5, 2022

    ContributorAuthor

    Since REditorSupport/vscode-R#803 already in place, this will lead to errors with the current version of the R extension.

    I suggest the following:

    1. @code-asher modifies Add proxy URI enviroment variable vscode#37 before releasing v4.0.1, i.e.
      diff --git a/src/vs/server/webClientServer.ts b/src/vs/server/webClientServer.ts
      index 9c0f0e1cf8f..d9e41798aa2 100644
      --- a/src/vs/server/webClientServer.ts
      +++ b/src/vs/server/webClientServer.ts
      @@ -320,7 +320,7 @@ export class WebClientServer {
                                              // Endpoints
                                              base,
                                              logoutEndpointUrl: base + '/logout',
      -                                       proxyEndpointUrlTemplate: base + '/proxy/{{port}}',
      +                                       proxyEndpointUrlTemplate: base + '/proxy/{port}',
                                              webEndpointUrl: vscodeBase + '/static',
                                              webEndpointUrlTemplate: vscodeBase + '/static',
                                              webviewContentExternalBaseUrlTemplate: vscodeBase + '/webview/{{uuid}}/',
    2. @code-asher is going to implement /proxy/{{port}} with the next release, assumingly v4.0.2.

    In the meantime and before releasing code-server v4.0.2:

    1. I am going to propose the following update in Support both single and double brackets in code-server's URI template REditorSupport/vscode-R#934:
      diff --git a/R/session/vsc.R b/R/session/vsc.R
      index c2f0695..8f0505a 100644
      --- a/R/session/vsc.R
      +++ b/R/session/vsc.R
      @@ -516,7 +516,7 @@ show_browser <- function(url, title = url, ...,
         if (nzchar(proxy_uri)) {
           is_base_path <- grepl("\\:\\d+$", url)
           url <- sub("^https?\\://(127\\.0\\.0\\.1|localhost)(\\:)?",
      -      sub("{port}", "", proxy_uri, fixed = TRUE), url)
      +      sub("\\{\\{?port\\}\\}?", "", proxy_uri), url)
           if (is_base_path) {
             url <- paste0(url, "/")
           }
      @@ -573,7 +573,7 @@ show_webview <- function(url, title, ..., viewer) {
         if (nzchar(proxy_uri)) {
           is_base_path <- grepl("\\:\\d+$", url)
           url <- sub("^https?\\://(127\\.0\\.0\\.1|localhost)(\\:)?",
      -      sub("{port}", "", proxy_uri, fixed = TRUE), url)
      +      sub("\\{\\{?port\\}\\}?", "", proxy_uri), url)
           if (is_base_path) {
             url <- paste0(url, "/")
           }

    ℹ️ This makes sure, that both versions (single brackets, double brackets) are handled correctly.

  22. code-asher commented on Jan 5, 2022

    Member

    Ahh I did not realize this was already implemented in vscode-R!

    I used double braces to match VS Code's own templating scheme they use with webview URIs. I will go ahead and move back to one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementSome improvement that isn't a feature

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL