fix(prod): déploiement docker fonctionnel — API_BASE_URL + wildcard loopback
- SameOriginHttpMessageHandler: quand Kestrel écoute sur une wildcard (0.0.0.0 / [::] — ASPNETCORE_URLS=http://+:8080 en conteneur), résoudre l'origine interne vers http://localhost:<port> au lieu de l'adresse anycast que le HttpClient ne peut pas joindre - docker-compose.prod.yml: API_BASE_URL explicite (http://localhost:8080) pour que les appels internes du circuit Blazor ciblent le listener du conteneur et non le port hôte vu par le navigateur - docker-compose.local.yml: override pour déployer l'image locale tant que les fixes ne sont pas publiés sur Docker Hub par la CI - .gitignore: exclut les .env (secrets JWT/mots de passe) Vérifié par smoke test Playwright contre la prod (127.0.0.1:5010) : login UI → dashboard, page users, création d'utilisateur, logout : 5/5
This commit is contained in:
1 parent
53b6240a3e
commit
42a441a7ab
4 files changed
+27
No files matched your search
@@ -81,3 +81,8 @@ coverage-report*/
|
||||
# Core dumps
|
||||
core.*
|
||||
templates/
|
||||
|
||||
# Secrets — never commit
|
||||
.env
|
||||
**/.env
|
||||
docker/.env
|
||||
@@ -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
|
||||
@@ -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}
|
||||
|
||||
@@ -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 + "/";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user