Appsilon / shiny.router

A minimalistic router for your Shiny apps.
http://appsilon.github.io/shiny.router
Other
256 stars 31 forks source link

[Bug]: 404 page does not work when a user opens a non-valid link without going to a valid one first #124

Closed jakubnowicki closed 1 year ago

jakubnowicki commented 1 year ago

Guidelines

Project Version

0.3.0

Platform and OS Version

No response

Existing Issues

No response

What happened?

404 page does not work when a user opens a non-valid link without going to a valid one first

Steps to reproduce

#Shiny Router 0.3.0 ----------
options(shiny.port = 3333)
install.packages("shiny.router@0.3.0") #Restart session if needed
library(shiny.router)
library(shiny)

router <- router_ui(
  route("/", shiny::tags$div(shiny::tags$span("Hello world"))),
  route("/main", shiny::tags$div(h1("Main page"), p("Lorem ipsum."))),
  page_404 = page404(tags$div(tags$h1("This is the 404 Page")))
)

shinyApp(
  router,
  function(input, output, session) {router_server()}
)

# 1. Visit http://localhost:3333/#!/non-existing-page directly (without ever visiting homepage) from your browser
# 2. Visit http://localhost:3333/#!/ first and then visit http://localhost:3333/#!/non-existing-page

Expected behavior

404 page is presented when a user opens a non-valid link.

Attachments

No response

Screenshots or Videos

No response

Additional Information

No response