refactor: simplify configuration handling for CMS URL
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 3m24s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 3m24s
- Removed CmsServerBaseUrl utility class and updated references to directly access GwUrl from configuration. - Adjusted frontoffice-deployment.yaml to remove CmsInternalBaseUrl environment variable. - Updated appsettings for staging and main environments to reflect the correct CMS service URLs. - Ensured consistent handling of GwUrl in TokenNotificationService and AddGrpcServices methods.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
---
|
---
|
||||||
# FrontOffice (Blazor Server) — staging. Server-side gRPC/SignalR to CMS: set CmsInternalBaseUrl to the
|
# FrontOffice (Blazor Server) staging.
|
||||||
# in-cluster Service URL so TLS is not terminated on a broken public chain (PartialChain).
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
@@ -29,8 +28,6 @@ spec:
|
|||||||
env:
|
env:
|
||||||
- name: ASPNETCORE_ENVIRONMENT
|
- name: ASPNETCORE_ENVIRONMENT
|
||||||
value: "Staging"
|
value: "Staging"
|
||||||
- name: CmsInternalBaseUrl
|
|
||||||
value: "http://cms-svc:8080"
|
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
memory: "256Mi"
|
memory: "256Mi"
|
||||||
|
|||||||
@@ -100,9 +100,7 @@ public static class ConfigureServices
|
|||||||
|
|
||||||
public static IServiceCollection AddGrpcServices(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddGrpcServices(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = CmsServerBaseUrl.Resolve(configuration)
|
var baseUrl = configuration["GwUrl"];
|
||||||
?? throw new InvalidOperationException(
|
|
||||||
"GwUrl is required. Optionally set CmsInternalBaseUrl (e.g. http://cms-svc:8080 on Kubernetes) to bypass public TLS for server-side gRPC.");
|
|
||||||
|
|
||||||
// Register optimized HttpClient for gRPC
|
// Register optimized HttpClient for gRPC
|
||||||
services.AddScoped(sp =>
|
services.AddScoped(sp =>
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
|
|
||||||
namespace FrontOffice.Main.Utilities;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Server-side base URL for CMS (gRPC-Web, SignalR). Prefer in-cluster HTTP when FrontOffice runs on Kubernetes
|
|
||||||
/// next to CMS to avoid public ingress TLS chain issues (e.g. PartialChain).
|
|
||||||
/// </summary>
|
|
||||||
public static class CmsServerBaseUrl
|
|
||||||
{
|
|
||||||
public static string? Resolve(IConfiguration configuration)
|
|
||||||
{
|
|
||||||
var internalUrl = configuration["CmsInternalBaseUrl"];
|
|
||||||
if (!string.IsNullOrWhiteSpace(internalUrl))
|
|
||||||
return internalUrl.TrimEnd('/');
|
|
||||||
return configuration["GwUrl"]?.TrimEnd('/');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -69,7 +69,7 @@ public class TokenNotificationService : IAsyncDisposable
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var gwUrl = CmsServerBaseUrl.Resolve(_configuration) ?? "https://localhost:5002";
|
var gwUrl = _configuration["GwUrl"]?.TrimEnd('/') ?? "https://localhost:5002";
|
||||||
var hubPath = _configuration["SignalR:HubPath"] ?? "/hubs/token-relay";
|
var hubPath = _configuration["SignalR:HubPath"] ?? "/hubs/token-relay";
|
||||||
var hubUrl = $"{gwUrl}{hubPath}";
|
var hubUrl = $"{gwUrl}{hubPath}";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"GwUrl": "https://cms.se.kbs1.ir",
|
"GwUrl": "http://cms-svc:8080",
|
||||||
"DownloadUrl": "",
|
"DownloadUrl": "",
|
||||||
"EncryptionSettings": {
|
"EncryptionSettings": {
|
||||||
"Key": "kmcQ3XTmH4mrdh8VHziuscyf8LLYjG//Kyni81nH/0E=",
|
"Key": "kmcQ3XTmH4mrdh8VHziuscyf8LLYjG//Kyni81nH/0E=",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"GwUrl": "https://localhost:32846",
|
"GwUrl": "https://cms.se.kbs1.ir",
|
||||||
"DownloadUrl": "",
|
"DownloadUrl": "",
|
||||||
"EncryptionSettings": {
|
"EncryptionSettings": {
|
||||||
"Key": "kmcQ3XTmH4mrdh8VHziuscyf8LLYjG//Kyni81nH/0E=",
|
"Key": "kmcQ3XTmH4mrdh8VHziuscyf8LLYjG//Kyni81nH/0E=",
|
||||||
|
|||||||
Reference in New Issue
Block a user