fix: make API client base URL configurable for green-blue deployments

Previously, all browser clients (AdminDashboardClient, InquiryBrowserClient, etc.)
had hardcoded BaseAddress of http://localhost:5001/taxbaik/api/. This caused
issues when implementing green-blue deployments where ports alternate between
5001/5002.

Changes:
- Add ApiClient:BaseUrl configuration in appsettings.json (default: 5001)
- Update Program.cs to read configuration instead of hardcoding
- All 6 browser clients now use dynamic configuration
- Deployment script prepared for green-blue support (port can be injected via
  ApiClient__BaseUrl environment variable)

Deployment Note:
- For green-blue: Set ApiClient__BaseUrl environment variable before starting
  the service on the alternate port (5002)
- Nginx still routes /taxbaik to the active instance
- Supports zero-downtime deployments

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-28 11:28:22 +09:00
parent 65c2dce8fe
commit 0d07b2d26a
5 changed files with 214 additions and 8 deletions
+10 -6
View File
@@ -76,34 +76,38 @@ builder.Services.AddScoped<INotificationService, NotificationService>();
builder.Services.AddScoped<ITokenStore, TokenStore>();
builder.Services.AddScoped<TokenRefreshHandler>();
builder.Services.AddHttpClient<IApiClient, ApiClient>();
var apiBaseUrl = builder.Configuration["ApiClient:BaseUrl"]
?? throw new InvalidOperationException("Missing configuration: ApiClient:BaseUrl");
builder.Services.AddHttpClient<IAdminDashboardClient, AdminDashboardClient>(client =>
{
client.BaseAddress = new Uri("http://localhost:5001/taxbaik/api/");
client.BaseAddress = new Uri(apiBaseUrl);
})
.AddHttpMessageHandler<TokenRefreshHandler>();
builder.Services.AddHttpClient<IInquiryBrowserClient, InquiryBrowserClient>(client =>
{
client.BaseAddress = new Uri("http://localhost:5001/taxbaik/api/");
client.BaseAddress = new Uri(apiBaseUrl);
})
.AddHttpMessageHandler<TokenRefreshHandler>();
builder.Services.AddHttpClient<IClientBrowserClient, ClientBrowserClient>(client =>
{
client.BaseAddress = new Uri("http://localhost:5001/taxbaik/api/");
client.BaseAddress = new Uri(apiBaseUrl);
})
.AddHttpMessageHandler<TokenRefreshHandler>();
builder.Services.AddHttpClient<ITaxFilingBrowserClient, TaxFilingBrowserClient>(client =>
{
client.BaseAddress = new Uri("http://localhost:5001/taxbaik/api/");
client.BaseAddress = new Uri(apiBaseUrl);
})
.AddHttpMessageHandler<TokenRefreshHandler>();
builder.Services.AddHttpClient<IFaqBrowserClient, FaqBrowserClient>(client =>
{
client.BaseAddress = new Uri("http://localhost:5001/taxbaik/api/");
client.BaseAddress = new Uri(apiBaseUrl);
})
.AddHttpMessageHandler<TokenRefreshHandler>();
builder.Services.AddHttpClient<IAnnouncementBrowserClient, AnnouncementBrowserClient>(client =>
{
client.BaseAddress = new Uri("http://localhost:5001/taxbaik/api/");
client.BaseAddress = new Uri(apiBaseUrl);
})
.AddHttpMessageHandler<TokenRefreshHandler>();