Group public routes under a common prefix (#974)

This commit is contained in:
Jonatan Kłosko 2022-02-03 17:48:16 +01:00 committed by GitHub
parent 70dac97ce7
commit fc8799ef8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View file

@ -124,7 +124,7 @@ defmodule LivebookCLI.Server do
defp check_endpoint_availability(base_url) do
Application.ensure_all_started(:inets)
health_url = append_path(base_url, "/health")
health_url = append_path(base_url, "/public/health")
case Livebook.Utils.HTTP.request(:get, health_url) do
{:ok, status, _headers, body} ->

View file

@ -20,7 +20,19 @@ defmodule LivebookWeb.Router do
plug :put_secure_browser_headers
end
scope "/", LivebookWeb do
# The /public namespace includes routes with no authentication.
# When exposing Livebook through an authentication proxy, this
# namespace should be configured as publicly available, in order
# for all features to work as expected.
scope "/public", LivebookWeb do
pipe_through :browser
get "/health", HealthController, :index
end
# The following routes are public, but should be treated as opaque
scope "/public", LivebookWeb do
pipe_through [:js_output_assets]
get "/sessions/assets/:hash/*file_parts", SessionController, :show_cached_asset
@ -78,13 +90,6 @@ defmodule LivebookWeb.Router do
ecto_repos: []
end
# Public URLs without authentication
scope "/", LivebookWeb do
pipe_through :browser
get "/health", HealthController, :index
end
scope "/authenticate", LivebookWeb do
pipe_through :browser