Open Brabin3 opened 2 years ago
Hey,
Yeah there is an issue with the way shiny proxy works — it iframes the actual app so there might be an issue with that.
I will have a look and let you know
Hey, Thank you!
Your help is greatly appreciated.
Has there been any progress made with using shinyProxy and Docker? I was looing to use this deployment avenue myself, @ColinFay @Brabin3
Two q for @Brabin3 :
-> Do you have specified a basepath
in your brochureApp ? by default brochure assumes that your app is at url/
, but shinyproxy deploys at url/myapp
-> Do the link inside your app redirect to url/myapp/mypage
or to url/mypage
?
@jjfantini I'll work on this, my only current issue is that it requires some time to have a shiny proxy running, a container with a brochure app, and all that is implied by that :)
@ColinFay that sounds great, I will try to flesh out issues here that I run into when deploying with this method, think it would be helpful for users down the road to have this one paved...looking forward to a fully isolated app environment that is isolated further with brochure -- the data flow design is much better when so explicit. Look forward to the journey ahead :) bear with me, v new to web dev
@ColinFay so the basepath
argument should be url/myapp
and the following brochurePages()
should be href = 'myapp/page'
?
I have something similar on shinyapps.io, where the apps url is: username.shinyapps.io/app_name
. Because the base url is /app_name
, and not just /
, the redirects also do not work out of the box.
I was able to get things working by:
baseurl = app_name
in run_app()
/pageX
to /app_name/pageX
So now things work well on shinyapps.io, but not locally, as the local url does not have the /app_name
suffix.
To fix this we can dynamically generate the redirect href based on getOption("baseurl"). Some function like:
#' make_href
#'
#' @description Add appropriate prefix to redirect link depending on context (option baseurl)
#' @param endpoint endpoint without leading `/`
#' @noRd
make_href <- function(endpoint) {
baseurl <- getOption("baseurl")
if (baseurl != "") {
paste0("/", baseurl, "/", endpoint, sep = "")
} else {
paste0("/", endpoint, sep = "")
}
}
Then, in /dev/run_dev.R
we can set
options(baseurl = "")
> make_href("")
[1] "/"
> make_href("page2")
[1] "/page2"
# then run app should work with unprefixed hrefs
run_app()
In 'production' mode on shinyapps.io, we can add the baseurl option in app.R
just before calling run_app()
:
options(baseurl = "my_app")
> make_href("")
[1] "/my_app/"
> make_href("page2")
[1] "/my_app/page2"
# then run app should work with prefixed hrefs
run_app()
Maybe something similar will work in shinyProxy?
I have built up a multi-page application using Brochure. I tried to deploy it using Docker & ShinyProxy deployment model. The app gets deployed and the first page alone loads. All other pages are missing when deployed with ShinyProxy (404).
In shiny Proxy application.yml file, container-cmd: ["R", "-e", "shiny::runApp('/root/euler')"]
When I tried to deploy the application without Brochure (i.e Single paged shiny app) then the deployment works.
Any help is greatly invited.