Images Appear when developing locally, but do not when Deployed on RStudioConnect

I have logos that appears on App with develop with RStudio, but when deployed to RStudio Connect they do not show up. No errors are thrown. Here is my server.R:

function(input, output, session) {
  user <- reactive({

    image_url <- glue::glue("assets/images/{user()}/{user()}.png")
        "document.getElementsByClassName('client-logo-container')[0].style.backgroundImage = 'url({image_url})';"

This is a very interesting use case! Can you say a bit more about the directory structure of your application? There are two different ways to reference files:

  • in R code, as a relative path from the R working directory
  • from the browser / front-end, referencing files that have been exposed over HTTP to the client

You are using the latter pattern, and if you want to continue using that pattern, you need to be sure that the path you are accessing (assets/images/myuser/myuser.png) exists relative to the application (i.e. you should be able to visit that URL in your browser and get an image). There are many ways to expose such files (canonical is the www/ directory).

However, it is important to recognize that this exposes all images at these paths (i.e. does not gate them by which user is looking at the application). The former pattern (referencing the files from R) can do this type of "only exposing the files for a particular user."

If you can say more about your directory structure, we should be able to help get this example working!