'Why does Shiny io deployal URL not work without extra path information
When I deploy an app using Shiny io, the URL (e.g., 'https://account.shinyapps.io/AppName/') does not work on other devices (sometimes the browser shows the error 'browser cannot connect to the server'). However, if the app is opened in shiny apps io dashboard then the full URL is copied from the address bar, the resulting URL will work on other devices (e.g., 'https://account.shinyapps.io/AppName/?_ga=2.202210006.61460828.1641729163-631729455.1649829163'). What would cause this?
Example of code used to create app:
library(shiny)
library(leaflet)
ui <- fluidPage(
# Application title
titlePanel("Radius"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
h4("Origin"),
numericInput(inputId = "originLat", label = "Latitude", value = 46.0),
numericInput(inputId = "originLong", label = "Longitude", value = -112.5),
h4("Radius"),
sliderInput(inputId = "RadiusMeters", label = "Meters", min = 0, max = 8000, value = 400, step = 400),
sliderInput(inputId = "RadiusMiles", label = "Miles", min = 0.00, max = 5, value = 400/1600, step = 0.25),
selectInput("View",
h4("Layer"),
choices = list("Aerial View" = 'Esri.WorldImagery',
"Topography" = 'OpenTopoMap',
"Street View" = 'OpenStreetMap.Mapnik'),
selected = 'OpenStreetMap.Mapnik'),
),
# Show a plot of the generated distribution
mainPanel(
leafletOutput("Area"),
)))
server <- function(input, output, session) {
observeEvent(input$RadiusMeters, {
updateSliderInput(session = session, inputId = "RadiusMiles", value = input$RadiusMeters / 1600)
})
observeEvent(input$RadiusMiles, {
updateSliderInput(session = session, inputId = "RadiusMeters", value = input$RadiusMiles * 1600)
})
output$Area <- renderLeaflet({
leaflet() %>%
addProviderTiles(input$View) %>%
setView(lng = (input$originLong), lat =(input$originLat), zoom = 13) %>%
addMarkers(lng=(input$originLong), lat=(input$originLat)) %>%
addCircles(lng=(input$originLong), lat=(input$originLat), radius = input$RadiusMeters)
})
session$onSessionEnded(function() {
stopApp()
})
}
UPDATE; I think what was happening was some sort of glitch. I published essentially the same thing as a new app and it works. I will leave this up for the time being in case some one has an explanation for this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
