Skip to content

Commit

Permalink
Fix bots url protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-Sanchez committed Sep 13, 2024
1 parent f429c98 commit ba051f7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apps/arena/lib/arena/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ defmodule Arena.Utils do

def get_bot_connection_url(game_id, bot_client) do
server_url = System.get_env("PHX_HOST") || "localhost"
bot_manager_host = System.get_env("BOT_MANAGER_HOST", "localhost")
bot_manager_port = System.get_env("BOT_MANAGER_PORT", "4003")
bot_manager_host = System.get_env("BOT_MANAGER_HOST", "localhost:4003")
protocol = get_correct_protocol(bot_manager_host)

"http://#{bot_manager_host}:#{bot_manager_port}/join/#{server_url}/#{game_id}/#{bot_client}"
"#{protocol}#{bot_manager_host}/join/#{server_url}/#{game_id}/#{bot_client}"
end

defp get_correct_protocol("localhost" <> _host), do: "http://"
defp get_correct_protocol(_host), do: "https://"
end

0 comments on commit ba051f7

Please sign in to comment.