From 29550401fded7d2e6b93aa6232120a2e069fdce6 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 18 Aug 2025 20:14:22 +0800 Subject: [PATCH] :sparkles: Add forwarded header across all gateway routes --- .../Startup/ServiceCollectionExtensions.cs | 7 ++++++- DysonNetwork.sln.DotSettings.user | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/DysonNetwork.Gateway/Startup/ServiceCollectionExtensions.cs b/DysonNetwork.Gateway/Startup/ServiceCollectionExtensions.cs index d147b14..53cef77 100644 --- a/DysonNetwork.Gateway/Startup/ServiceCollectionExtensions.cs +++ b/DysonNetwork.Gateway/Startup/ServiceCollectionExtensions.cs @@ -2,6 +2,7 @@ using System.Net.Security; using System.Security.Cryptography.X509Certificates; using DysonNetwork.Shared.Registry; using Yarp.ReverseProxy.Configuration; +using Yarp.ReverseProxy.Transforms; namespace DysonNetwork.Gateway.Startup; @@ -15,11 +16,15 @@ public static class ServiceCollectionExtensions .AddReverseProxy() .ConfigureHttpClient((context, handler) => { - var caCert = X509CertificateLoader.LoadCertificateFromFile(configuration["CaCert"]!); + // var caCert = X509CertificateLoader.LoadCertificateFromFile(configuration["CaCert"]!); handler.SslOptions = new SslClientAuthenticationOptions { RemoteCertificateValidationCallback = (sender, cert, chain, errors) => true }; + }) + .AddTransforms(context => + { + context.AddForwarded(); }); services.AddRegistryService(configuration, addForwarder: false); diff --git a/DysonNetwork.sln.DotSettings.user b/DysonNetwork.sln.DotSettings.user index 2eace75..e5c3a1b 100644 --- a/DysonNetwork.sln.DotSettings.user +++ b/DysonNetwork.sln.DotSettings.user @@ -57,6 +57,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded @@ -120,6 +121,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded