Distinguishing local app from shiny server

I have an app that I want to behave differently when it is on a shiny server versus running in RStudio. Is there a field in the session variable that will allow me to identify when I'm running an app on the shiny server vs a locally running app?

One way to identify local vs server could be checking the url pattern session$clientData$url_hostname

Another way (that I use for sql connections) could be checking the OS with a function, but this is not as generalizable as the previous one.

get_os <- function(){
    sysinf <- Sys.info()
    os <- sysinf['sysname']
    if (os == 'Darwin'){
        os <- "osx"
    } else { ## mystery machine
    os <- .Platform$OS.type
    if (grepl("^darwin", R.version$os))
        os <- "osx"
    if (grepl("linux-gnu", R.version$os))
        os <- "linux"
    if (grepl("linux-gnueabihf", R.version$os))
        os <- "raspbian"


What about setting a flag in Global.R based on testing if a local.text file exists or not?



This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.