From b372a426816c370f39d270e75686ebb658509471 Mon Sep 17 00:00:00 2001 From: Alan Guzek Date: Wed, 28 May 2025 11:08:36 +0200 Subject: [PATCH] Task: Add custom LiveDebugger url config (#438) * add config for managing external url --- README.md | 3 +++ docs/config.md | 3 +++ lib/live_debugger.ex | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3a97f5832..6fbd3548c 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,9 @@ config :live_debugger, :debug_button?, false # Disables only components highlighting config :live_debugger, :highlighting?, false + +# Used when LiveDebugger's assets are exposed on other address (e.g. when run inside Docker) +config :live_debugger, :external_url, "http://localhost:9007" ``` ### Content Security Policy diff --git a/docs/config.md b/docs/config.md index d96a69e44..e8d174570 100644 --- a/docs/config.md +++ b/docs/config.md @@ -13,6 +13,9 @@ config :live_debugger, :debug_button?, false # Disables only components highlighting config :live_debugger, :highlighting?, false + +# Used when LiveDebugger's assets are exposed on other address (e.g. when run inside Docker) +config :live_debugger, :external_url, "http://localhost:9007" ``` ### Content Security Policy diff --git a/lib/live_debugger.ex b/lib/live_debugger.ex index 646d4ee6f..5b58f41d5 100644 --- a/lib/live_debugger.ex +++ b/lib/live_debugger.ex @@ -80,13 +80,14 @@ defmodule LiveDebugger do defp put_live_debugger_tags(config) do ip_string = config |> Keyword.get(:ip, @default_ip) |> :inet.ntoa() |> List.to_string() port = Keyword.get(config, :port, @default_port) + live_debugger_url = "http://#{ip_string}:#{port}" browser_features? = Keyword.get(config, :browser_features?, true) debug_button? = Keyword.get(config, :debug_button?, true) highlighting? = Keyword.get(config, :highlighting?, true) + external_url = Keyword.get(config, :external_url, live_debugger_url) - live_debugger_url = "http://#{ip_string}:#{port}" - live_debugger_assets_url = "http://#{ip_string}:#{port}/#{@assets_path}" + live_debugger_assets_url = "#{external_url}/#{@assets_path}" assigns = %{ url: live_debugger_url,