diff --git a/k8s/staging/frontoffice-deployment.yaml b/k8s/staging/frontoffice-deployment.yaml index 989e9a2..88b5cf3 100644 --- a/k8s/staging/frontoffice-deployment.yaml +++ b/k8s/staging/frontoffice-deployment.yaml @@ -28,6 +28,10 @@ spec: env: - name: ASPNETCORE_ENVIRONMENT value: "Staging" + - name: GW_URL + value: "https://cms.se.kbs1.ir" + - name: GwUrl + value: "https://cms.se.kbs1.ir" resources: requests: memory: "256Mi" diff --git a/src/FrontOffice.Main/ConfigureServices.cs b/src/FrontOffice.Main/ConfigureServices.cs index d449a5a..e26f7b2 100644 --- a/src/FrontOffice.Main/ConfigureServices.cs +++ b/src/FrontOffice.Main/ConfigureServices.cs @@ -100,7 +100,8 @@ public static class ConfigureServices public static IServiceCollection AddGrpcServices(this IServiceCollection services, IConfiguration configuration) { - var baseUrl = configuration["GwUrl"]; + var baseUrl = ResolveGatewayUrl(configuration) + ?? throw new InvalidOperationException("Gateway URL is missing. Set GW_URL or GwUrl."); // Register optimized HttpClient for gRPC services.AddScoped(sp => @@ -152,6 +153,15 @@ public static class ConfigureServices return services; } + private static string? ResolveGatewayUrl(IConfiguration configuration) + { + var envUrl = configuration["GW_URL"]; + if (!string.IsNullOrWhiteSpace(envUrl)) + return envUrl.TrimEnd('/'); + + return configuration["GwUrl"]?.TrimEnd('/'); + } + private static TClient CreateAuthenticatedClient(IServiceProvider sp) where TClient : class { diff --git a/src/FrontOffice.Main/Dockerfile b/src/FrontOffice.Main/Dockerfile index 0320861..e6c235e 100644 --- a/src/FrontOffice.Main/Dockerfile +++ b/src/FrontOffice.Main/Dockerfile @@ -21,6 +21,7 @@ WORKDIR /app COPY --from=build /app/publish . ENV ASPNETCORE_URLS=http://+:80 +ENV GW_URL=https://cms.se.kbs1.ir EXPOSE 80 ENTRYPOINT ["dotnet", "FrontOffice.Main.dll"] diff --git a/src/FrontOffice.Main/Utilities/TokenNotificationService.cs b/src/FrontOffice.Main/Utilities/TokenNotificationService.cs index 7912dc6..b48609e 100644 --- a/src/FrontOffice.Main/Utilities/TokenNotificationService.cs +++ b/src/FrontOffice.Main/Utilities/TokenNotificationService.cs @@ -69,7 +69,7 @@ public class TokenNotificationService : IAsyncDisposable return; } - var gwUrl = _configuration["GwUrl"]?.TrimEnd('/') ?? "https://localhost:5002"; + var gwUrl = (_configuration["GW_URL"] ?? _configuration["GwUrl"])?.TrimEnd('/') ?? "https://localhost:5002"; var hubPath = _configuration["SignalR:HubPath"] ?? "/hubs/token-relay"; var hubUrl = $"{gwUrl}{hubPath}";