You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Modify function browser / argument url (options) to allow proxied requests #275
Seems like they’ve got the /proxy/<number> scheme working on the code-server side. Where in the codebase should we need to make the proposed change? This is blocking both help docs and Shiny apps for code-server deployments (in that users would have to manually replace 127.0.0.1 with the URL of the code-server instance).
I'm trying to get VSCODE_HTTP_REFERER accepted as environment variable.
👉 The name of their ancestor; a common name to implement the functionality for Ikuyadeu/vscode-R in all of VS Code derivatives (e.g. Eclipse Theia and code-server) - if their collaborators decide to do so.
Alternaively HTTP_REFERER; neutral, not mentioning a product name.
diff --git a/R/session/vsc.R b/R/session/vsc.R
index cc17286..90a8bf7 100644
--- a/R/session/vsc.R+++ b/R/session/vsc.R@@ -494,11 +494,23 @@ request_browser <- function(url, title, ..., viewer) {
show_browser <- function(url, title = url, ...,
viewer = getOption("vsc.browser", "Active")) {
+ if (nzchar(Sys.getenv("VSCODE_PROXY_URI"))) {+ is.base_path <- grepl("\\:\\d+$", url)+ url <- sub("^https?\\://(127\\.0\\.0\\.1|localhost)(\\:)?",+ sub("\\{port\\}", "", Sys.getenv("VSCODE_PROXY_URI")), url)+ if (is.base_path) {+ url <- paste0(url, "/")+ }+ }
if (grepl("^https?\\://(127\\.0\\.0\\.1|localhost)(\\:\\d+)?", url)) {
request_browser(url = url, title = title, ..., viewer = viewer)
} else if (grepl("^https?\\://", url)) {
message(
- "VSCode WebView only supports showing local http content.\n",+ if (nzchar(Sys.getenv("VSCODE_PROXY_URI"))) {+ "VSCode is not running on localhost but on a remote server.\n"+ } else {+ "VSCode WebView only supports showing local http content.\n"+ },
"Opening in external browser..."
)
request_browser(url = url, title = title, ..., viewer = FALSE)
@@ -535,11 +547,23 @@ show_webview <- function(url, title, ..., viewer) {
stop("Invalid object")
}
}
+ if (nzchar(Sys.getenv("VSCODE_PROXY_URI"))) {+ is.base_path <- grepl("\\:\\d+$", url)+ url <- sub("^https?\\://(127\\.0\\.0\\.1|localhost)(\\:)?",+ sub("\\{port\\}", "", Sys.getenv("VSCODE_PROXY_URI")), url)+ if (is.base_path) {+ url <- paste0(url, "/")+ }+ }
if (grepl("^https?\\://(127\\.0\\.0\\.1|localhost)(\\:\\d+)?", url)) {
request_browser(url = url, title = title, ..., viewer = viewer)
} else if (grepl("^https?\\://", url)) {
message(
- "VSCode WebView only supports showing local http content.\n",+ if (nzchar(Sys.getenv("VSCODE_PROXY_URI"))) {+ "VSCode is not running on localhost but on a remote server.\n"+ } else {+ "VSCode WebView only supports showing local http content.\n"+ },
"Opening in external browser..."
)
request_browser(url = url, title = title, ..., viewer = FALSE)
will open shiny apps, htmlwidgets, etc. in separate browser windows on code-server if environment variable VSCODE_PROXY_URI is set. Should options(vsc.helpPanel = FALSE), this is also true for the help panel when called from R terminal.
This does not affect the behaviour of the 'Help viewer' from the R extension itself, though. And 'R Help Panel: Open in external browser' will still use http://localhost:${this.port}/${requestPath}.
👉 Unfortunately, I can't tell you which modifications have to be applied to the helpViewer scripts.
options(vsc.use_httpgd = TRUE) (the SVG plot viewer based on httpgd) works well on code-server.
'Open in external Browser' currently fails because httpgd.ts does not consider VSCODE_PROXY_URI.
ℹ️ Even if VSCODE_PROXY_URI could be considered, the request would fail throwing error Uncaught DOMException: The operation is insecure. with my setup, as code-server is served via JupyterHub and neither VSCODE_PROXY_URI nor JUPYTERHUB_API_TOKEN currently being considered when requesting the httpgd API endpoints.
Using the SVG plot viewer based on httpgd without being able to open it in an external Browser is absolutely OK.
👉 I don't expect all features of the R extension to properly work with a code-server deployment.
@renkun-ken You may test on https://vscode-r.jupyter.b-data.ch, which has environment variable VSCODE_PROXY_URI set and the modified vsc.R in place.
ℹ️ Sign in with your GitHub account which is whitelisted.
Activity
kevinykuo commentedon Jan 30, 2021
Seems like they’ve got the
/proxy/<number>scheme working on the code-server side. Where in the codebase should we need to make the proposed change? This is blocking both help docs and Shiny apps for code-server deployments (in that users would have to manually replace127.0.0.1with the URL of the code-server instance).benz0li commentedon Jun 12, 2021
@renkun-ken I'm going to ask the Coder guys about the environment variable
VSCODE_HTTP_REFERER(orCODE_SERVER_HTTP_REFERER?) again.benz0li commentedon Jun 14, 2021
I'm trying to get
VSCODE_HTTP_REFERERaccepted as environment variable.👉 The name of their ancestor; a common name to implement the functionality for Ikuyadeu/vscode-R in all of VS Code derivatives (e.g. Eclipse Theia and code-server) - if their collaborators decide to do so.
Alternaively
HTTP_REFERER; neutral, not mentioning a product name.benz0li commentedon Sep 16, 2021
PR coder/code-server#3621 should be part of the next code-server release.
The environment variable will be named
VSCODE_PROXY_URI.benz0li commentedon Sep 28, 2021
@renkun-ken Applying patch
will open shiny apps, htmlwidgets, etc. in separate browser windows on code-server if environment variable
VSCODE_PROXY_URIis set. Shouldoptions(vsc.helpPanel = FALSE), this is also true for the help panel when called from R terminal.This does not affect the behaviour of the 'Help viewer' from the R extension itself, though. And 'R Help Panel: Open in external browser' will still use
http://localhost:${this.port}/${requestPath}.👉 Unfortunately, I can't tell you which modifications have to be applied to the helpViewer scripts.
benz0li commentedon Sep 28, 2021
options(vsc.use_httpgd = TRUE)(the SVG plot viewer based on httpgd) works well on code-server.'Open in external Browser' currently fails because httpgd.ts does not consider
VSCODE_PROXY_URI.ℹ️ Even if
VSCODE_PROXY_URIcould be considered, the request would fail throwing errorUncaught DOMException: The operation is insecure.with my setup, as code-server is served via JupyterHub and neitherVSCODE_PROXY_URInorJUPYTERHUB_API_TOKENcurrently being considered when requesting the httpgd API endpoints.Using the SVG plot viewer based on httpgd without being able to open it in an external Browser is absolutely OK.
👉 I don't expect all features of the R extension to properly work with a code-server deployment.
benz0li commentedon Sep 28, 2021
@renkun-ken You may test on https://vscode-r.jupyter.b-data.ch, which has environment variable
VSCODE_PROXY_URIset and the modifiedvsc.Rin place.ℹ️ Sign in with your GitHub account which is whitelisted.
renkun-ken commentedon Sep 28, 2021
Thanks for digging into this.
I tried the testing environment and it looks awesome!
The following features work:
plot(rnorm(100))?getDT::datatable(mtcars)The following do not work at the moment:
View(mtcars)benz0li commentedon Sep 28, 2021
Thanks for the prompt feedback.
I've just recently updated the R extension from v1.6.8 to v2.3.0.
Might be related to #708 as the data viewer worked with v1.6.8.benz0li commentedon Sep 28, 2021
Most probably related to coder/code-server#4075 (reply in thread).
benz0li commentedon Sep 28, 2021
@renkun-ken Should I prepare a pull request for the changes in
vsc.R?renkun-ken commentedon Sep 28, 2021
@benz0li Sure, please.
benz0li commentedon Sep 29, 2021
@renkun-ken This issue may be closed, as I do not consider possible modifications to the helpViewer scripts and plotViewer scripts to be relevant to this issue.
benz0li commentedon Dec 3, 2021
@renkun-ken
View(mtcars)works now. Not sure why, though.Updated this extension from v2.3.0 to v2.3.3. code-server hasn't been updated in the meantime.