refactor(web-client-tpos): dashboard data-driven, 2-level sidebar, fix YARP 502 in Docker
This commit is contained in:
@@ -16,6 +16,50 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
// VI: Load cấu hình YARP từ yarp.json
|
||||
builder.Configuration.AddJsonFile("yarp.json", optional: false, reloadOnChange: true);
|
||||
|
||||
// EN: Override YARP cluster addresses from Docker environment variables
|
||||
// VI: Override địa chỉ YARP cluster từ biến môi trường Docker
|
||||
var iamBaseUrl = Environment.GetEnvironmentVariable("IamService__BaseUrl");
|
||||
var gatewayUrl = Environment.GetEnvironmentVariable("ApiSettings__GatewayUrl");
|
||||
|
||||
if (!string.IsNullOrEmpty(iamBaseUrl))
|
||||
{
|
||||
builder.Configuration["ReverseProxy:Clusters:iam-cluster:Destinations:destination1:Address"] = iamBaseUrl;
|
||||
}
|
||||
|
||||
// EN: Merchant service — discover via env or construct from gateway naming convention
|
||||
// VI: Merchant service — phát hiện qua env hoặc tạo từ naming convention gateway
|
||||
var merchantBaseUrl = Environment.GetEnvironmentVariable("MerchantService__BaseUrl");
|
||||
if (string.IsNullOrEmpty(merchantBaseUrl) && !string.IsNullOrEmpty(iamBaseUrl))
|
||||
{
|
||||
// EN: If no explicit merchant URL, try to construct from Docker network naming
|
||||
// VI: Nếu không có URL merchant rõ ràng, thử tạo từ Docker network naming
|
||||
merchantBaseUrl = iamBaseUrl.Replace("iam-service-net", "merchant-service-net");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(merchantBaseUrl))
|
||||
{
|
||||
builder.Configuration["ReverseProxy:Clusters:merchant-cluster:Destinations:destination1:Address"] = merchantBaseUrl;
|
||||
}
|
||||
|
||||
var catalogBaseUrl = Environment.GetEnvironmentVariable("CatalogService__BaseUrl");
|
||||
if (string.IsNullOrEmpty(catalogBaseUrl) && !string.IsNullOrEmpty(iamBaseUrl))
|
||||
{
|
||||
catalogBaseUrl = iamBaseUrl.Replace("iam-service-net", "catalog-service-net");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(catalogBaseUrl))
|
||||
{
|
||||
builder.Configuration["ReverseProxy:Clusters:catalog-cluster:Destinations:destination1:Address"] = catalogBaseUrl;
|
||||
}
|
||||
|
||||
var orderBaseUrl = Environment.GetEnvironmentVariable("OrderService__BaseUrl");
|
||||
if (string.IsNullOrEmpty(orderBaseUrl) && !string.IsNullOrEmpty(iamBaseUrl))
|
||||
{
|
||||
orderBaseUrl = iamBaseUrl.Replace("iam-service-net", "order-service-net");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(orderBaseUrl))
|
||||
{
|
||||
builder.Configuration["ReverseProxy:Clusters:order-cluster:Destinations:destination1:Address"] = orderBaseUrl;
|
||||
}
|
||||
|
||||
// EN: Add YARP Reverse Proxy
|
||||
// VI: Thêm YARP Reverse Proxy
|
||||
builder.Services.AddReverseProxy()
|
||||
|
||||
Reference in New Issue
Block a user