diff --git a/.gitignore b/.gitignore index c528db7..0eb7757 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,8 @@ coverage-report*/ # Core dumps core.* templates/ + +# Secrets — never commit +.env +**/.env +docker/.env diff --git a/docker/docker-compose.local.yml b/docker/docker-compose.local.yml new file mode 100644 index 0000000..4b23c68 --- /dev/null +++ b/docker/docker-compose.local.yml @@ -0,0 +1,10 @@ +# ─── Heimdall — Override: use locally-built image with current fixes ─── +# The Docker Hub image (eltruncho/heimdall:latest) is published by CI on +# main pushes; until the fixes are pushed, deploy the local image instead. +# Usage: docker compose --env-file docker/.env -f docker/docker-compose.prod.yml -f docker/docker-compose.local.yml up -d +services: + heimdall: + image: heimdall:local + build: + context: .. + dockerfile: docker/Dockerfile diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml index 6fd856c..a5a7bbb 100644 --- a/docker/docker-compose.prod.yml +++ b/docker/docker-compose.prod.yml @@ -87,6 +87,9 @@ services: ASPNETCORE_URLS: http://+:8080 # CORS (for external agents and API clients) Cors__AllowedOrigins: ${Cors__AllowedOrigins:-*} + # Monolith: internal HTTP calls (circuit-triggered) must target the + # container's own listener, NOT the host-mapped origin the browser sees. + API_BASE_URL: ${API_BASE_URL:-http://localhost:8080} # Error tracking SENTRY_DSN: ${SENTRY_DSN} Sentry__Dsn: ${Sentry__Dsn} diff --git a/src/Heimdall.Web/Services/SameOriginHttpMessageHandler.cs b/src/Heimdall.Web/Services/SameOriginHttpMessageHandler.cs index 0bca067..fa01758 100644 --- a/src/Heimdall.Web/Services/SameOriginHttpMessageHandler.cs +++ b/src/Heimdall.Web/Services/SameOriginHttpMessageHandler.cs @@ -61,6 +61,15 @@ public static class ApiBaseUrlResolver if (string.IsNullOrWhiteSpace(httpAddress)) return null; + // Wildcard binds (0.0.0.0 / [::]) cannot be dialed by an HttpClient — + // replace the host with loopback, keeping the bound port. + if (httpAddress.Contains("0.0.0.0", StringComparison.OrdinalIgnoreCase) + || httpAddress.Contains("[::]", StringComparison.OrdinalIgnoreCase)) + { + var port = new Uri(httpAddress).Port; + httpAddress = $"http://localhost:{port}/"; + } + // http://127.0.0.1:5000 -> http://127.0.0.1:5000/ return httpAddress.EndsWith('/') ? httpAddress : httpAddress + "/"; }