You can set up your plumber2 api to act as reverse proxy and forward all
requests to a specific path (and it's subpaths) to a different URL. In
contrast to api_shiny()
, api_forward()
is not responsible for launching
whatever service is being proxied so this should be handled elsewhere. The
path
will be stripped from the request before being forwarded to the url,
meaning that if you set up a proxy on my/proxy/
to http://example.com
,
then a request for my/proxy/user/thomas
will end at
http://example.com/user/thomas
. Proxying is most useful when forwarding to
internal servers though you are free to forward to public URLs as well.
However, for the later you'd usually use a redirect instead (via
api_redirect()
)
Examples
# Serve wikipedia directly from your app
api() |>
api_forward("my_wiki/", "https://www.wikipedia.org")
#> ── A plumber server ────────────────────────────────────────────────────────────
#> Serving on http://127.0.0.1:8080
#> Currently not running