Skip to content

Commit

Permalink
Fix bug in setting openapi.json url when HTTP_REFERER is null rstudio…
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Tremblay committed Apr 17, 2020
1 parent b7ff05a commit f9d713d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ plumber 0.5.0

### Bug fixes

* Fix bug in setting openapi.json url when HTTP_REFERER is null (@meztez,
[#421](https://github.com/rstudio/plumber/issues/421))

* Fix possible bugs due to mounted routers without leading slashes (@atheriel, [#476](https://github.com/rstudio/plumber/issues/476) [#501](https://github.com/rstudio/plumber/pull/501)).

* Fix bug preventing error handling when a serializer fails (@antoine-sachet, [#490](https://github.com/rstudio/plumber/pull/490))
Expand Down
11 changes: 7 additions & 4 deletions R/plumber.R
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,15 @@ plumber <- R6Class(
# ex: rstudio cloud
# use the HTTP_REFERER so RSC can find the swagger location to ask
## (can't directly ask for 127.0.0.1)
referrer_url <- req$HTTP_REFERER
referrer_url <- sub("index\\.html$", "", referrer_url)
referrer_url <- sub("__swagger__/$", "", referrer_url)
if (is.null(req$HTTP_REFERER)) {
openapi_server_url <- getOption("plumber.openapi.server.url")
} else {
openapi_server_url <- sub("index\\.html$|__swagger__/$", "", req$HTTP_REFERER)
options("plumber.openapi.server.url" = openapi_server_url)
}
spec$servers <- list(
list(
url = referrer_url,
url = openapi_server_url,
description = "OpenAPI"
)
)
Expand Down

0 comments on commit f9d713d

Please sign in to comment.