Compare commits

...

2 Commits

Author SHA1 Message Date
hadley
71d20d3561 Document (GitHub Actions) 2021-07-04 19:45:24 +00:00
Hadley Wickham
32ac62f2a3 Get imputed URL for current app/session 2021-07-04 14:41:30 -05:00
3 changed files with 53 additions and 2 deletions

View File

@@ -2126,6 +2126,51 @@ ShinySession <- R6Class(
}
})
}
},
getUrl = function() {
req <- self$request
url <-
# Connect
req[["HTTP_X_RSC_REQUEST"]] %||%
req[["HTTP_RSTUDIO_CONNECT_APP_BASE_URL"]] %||%
# ShinyApps.io
if (!is.null(req[["HTTP_X_REDX_FRONTEND_NAME"]])) {
paste0("https://", req[["HTTP_X_REDX_FRONTEND_NAME"]])
}
if (is.null(url)) {
forwarded_host <- req[["HTTP_X_FORWARDED_HOST"]]
forwarded_port <- req[["HTTP_X_FORWARDED_PORT"]]
host <- if (!is.null(forwarded_host) && !is.null(forwarded_port)) {
paste0(forwarded_host, ":", forwarded_port)
} else {
req[["HTTP_HOST"]] %||% paste0(req[["SERVER_NAME"]], ":", req[["SERVER_PORT"]])
}
proto <- req[["HTTP_X_FORWARDED_PROTO"]] %||% req[["rook.url_scheme"]]
if (tolower(proto) == "http") {
host <- sub(":80$", "", host)
} else if (tolower(proto) == "https") {
host <- sub(":443$", "", host)
}
url <- paste0(
proto,
"://",
host,
req[["SCRIPT_NAME"]],
req[["PATH_INFO"]]
)
}
# Strip existing querystring, if any
url <- sub("\\?.*", "", url)
url
}
)
)

View File

@@ -30,7 +30,10 @@ expression that produces a Shiny app object.
\item{port}{The TCP port that the application should listen on. If the
\code{port} is not specified, and the \code{shiny.port} option is set (with
\code{options(shiny.port = XX)}), then that port will be used. Otherwise,
use a random port.}
use a random port between 3000:8000, excluding ports that are blocked
by Google Chrome for being considered unsafe: 3659, 4045, 5060,
5061, 6000, 6566, 6665:6669 and 6697. Up to twenty random
ports will be tried.}
\item{launch.browser}{If true, the system's default web browser will be
launched automatically after the app is started. Defaults to true in

View File

@@ -19,7 +19,10 @@ list the available examples.}
\item{port}{The TCP port that the application should listen on. If the
\code{port} is not specified, and the \code{shiny.port} option is set (with
\code{options(shiny.port = XX)}), then that port will be used. Otherwise,
use a random port.}
use a random port between 3000:8000, excluding ports that are blocked
by Google Chrome for being considered unsafe: 3659, 4045, 5060,
5061, 6000, 6566, 6665:6669 and 6697. Up to twenty random
ports will be tried.}
\item{launch.browser}{If true, the system's default web browser will be
launched automatically after the app is started. Defaults to true in