Determines whether the current R session is running in a hosted environment such as Google Colab or RStudio Server (non-localhost).
Value
A logical value: TRUE if running in a hosted session (Google Colab
or remote RStudio Server), FALSE otherwise.
Details
This function checks for:
Google Colab: presence of the
COLAB_RELEASE_TAGenvironment variableRStudio Server:
RSTUDIO_PROGRAM_MODEis "server" andRSTUDIO_HTTP_REFERERdoes not contain "localhost"
Examples
if (is_hosted_session()) {
message("Running in a hosted environment")
}