From 8cc9355286a7393fadb8bd72c0c50a42d99a2c04 Mon Sep 17 00:00:00 2001 From: Adrian Gruntkowski Date: Fri, 7 Feb 2025 14:47:54 +0100 Subject: [PATCH] Differentiate Bandit port between test and other envs --- config/runtime.exs | 4 ++++ lib/jenot/application.ex | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config/runtime.exs b/config/runtime.exs index 9e97417..a949407 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -2,6 +2,10 @@ import Config config :jenot, host: System.fetch_env!("HOST") +port = if config_env() == :test, do: 4001, else: 4000 + +config :jenot, port: port + config :jenot, secret_key_base: System.fetch_env!("SECRET_KEY_BASE") config :jenot, secure_cookie: System.fetch_env!("SECURE_COOKIE") == "true" diff --git a/lib/jenot/application.ex b/lib/jenot/application.ex index fae6fb7..2312fbf 100644 --- a/lib/jenot/application.ex +++ b/lib/jenot/application.ex @@ -9,7 +9,7 @@ defmodule Jenot.Application do children = [ Jenot.Repo, - {Bandit, plug: Jenot.Web, scheme: :http, port: 4000} + {Bandit, plug: Jenot.Web, scheme: :http, port: Application.fetch_env!(:jenot, :port)} ] opts = [strategy: :one_for_one, name: Jenot.Supervisor]