-
Notifications
You must be signed in to change notification settings - Fork 130
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
Modify function browser / argument url (options) to allow proxied requests #275
Comments
Seems like they’ve got the |
@renkun-ken I'm going to ask the Coder guys about the environment variable |
I'm trying to get Alternaively |
PR coder/code-server#3621 should be part of the next code-server release. The environment variable will be named |
@renkun-ken Applying patch 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 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 |
'Open in external Browser' currently fails because httpgd.ts does not consider Using the SVG plot viewer based on httpgd without being able to open it in an external Browser is absolutely OK. |
@renkun-ken You may test on https://vscode-r.jupyter.b-data.ch, which has environment variable |
Thanks for digging into this. I tried the testing environment and it looks awesome! The following features work:
The following do not work at the moment:
|
Thanks for the prompt feedback. I've just recently updated the R extension from v1.6.8 to v2.3.0. |
Most probably related to coder/code-server#4075 (reply in thread). |
@renkun-ken Should I prepare a pull request for the changes in |
@benz0li Sure, please. |
@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. |
@renkun-ken Updated this extension from v2.3.0 to v2.3.3. code-server hasn't been updated in the meantime. |
Is your feature request related to a problem? Please describe.
On code-server it is currently impossible to access HTML help or view Shiny Apps.
This is because the
url
points to127.0.0.1
(localhost
) instead of the URL at which code-server ist running. Related to Issue #192.Describe the solution you'd like
At Coder they are working on a HTTP proxy, which will enable port forwarding using path
/proxy/<number>
.Is there a way to modify function
browser
/ argumenturl
(options) to use the proxied address instead of127.0.0.1
?It needs to be clarified how a local (VS Code) installation can be differentiated from a server (code-server) installation.
Describe alternatives you've considered
One could check the port used by the httpd help server or Shiny app, open a new browser window and fill in the URL to be proxied.
Additional context
Maybe it is worth looking on how RStudio handles
url
differently for Shiny Apps on the Desktop and Server version.The text was updated successfully, but these errors were encountered: