Hi,
So I'm trying to get a vitessceR widget running in a shiny app and publish on R Studio Connect (RSC). The app runs and works on the local machine; vitessce can listen and find data files through localhost. However, when published to RSC the widget cannot find the files bundled with it.
Since the visualizations in Vitessce are rendered completely in the browser, the big question in a deployment setting is how to serve data files in a way that the Vitessce frontend can access them (from a browser environment that is not necessarily local to the data files/server). The Vitessce Python and R packages use lightweight web server packages (plumber in R, hypercorn in Python) by default to serve local data on localhost, but this will not work in a deployment setting because localhost is meaningless to remote clients.
The authors of the widget suggest replacing the built-in server for Shiny's addResourcePath. However, I found that this does not work normally on RSC. The minimal code example below does not seem to function on the platform:
library(shiny)
if(!dir.exists("www")){
dir.create("www")
}
addResourcePath(prefix = "www", directoryPath = "./www")
png(filename = file.path("./www/test.png"))
x <- 1:50
y <- runif(50)
plot(x, y, type = "l")
invisible(dev.off())
ui <- fluidPage(
tags$img(src = "www/test.png")
)
server <- function(input, output, session) {}
app <- shinyApp(ui, server)
runApp(app)
I've also looked into session$clientData on RSC but the session$clientData$url_pathname and session$clientData$url_search both return 404 errors so I assume they don't work on RSC for security reasons. I'm blocked now trying to figure out how to serve data to this widget on RSC without having to host the data files on another web host.
My question is this : After publishing an app bundle to R Studio Connect, is it possible to serve local data from the app working directory using the RSC web server? If so, is there a url path I should point my frontend code to? If not, does anyone know how can I configure a htmlwidget to read from current working directory instead of looking for a url?
I can elaborate further if my question is unclear.