Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to redirect to /docs/ not the /__docs__/? #941

Closed
wikithink opened this issue Dec 23, 2023 · 1 comment
Closed

how to redirect to /docs/ not the /__docs__/? #941

wikithink opened this issue Dec 23, 2023 · 1 comment

Comments

@wikithink
Copy link

wikithink commented Dec 23, 2023

I have a problem,I have to redirect to /docs/ not the /__docs__/ in my team,but not using nginx,how to do that?
I modify the ui.R,but error following:
Fetch errorNot Found http://ip:port/docs/openapi.json

thanks very much!

@thomasp85
Copy link
Collaborator

I think the easiest way to solve this is by providing a permanent redirect /__docs__/ from /docs/.

The location is hardcoded so there is no way currently to have it natively at a different location

redirect <- function(to) {
  function(req, res) {
    res$status <- 301
    res$setHeader("Location", to)
    res$body <- "redirecting..."
    res
  }
}

pr() |>
  pr_get("/docs/", redirect("../__docs__/")) |> 
  pr_get("/docs/index.html", redirect("../__docs__/index.html")) |> 
  pr_run()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants