From 44cfd3ebcd8fc8cce27df9d0c66b12de92979b5c Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期二, 10 十一月 2026 17:08:22 +0800
Subject: [PATCH] 网关添加 扩展名过滤,响应页面拦截器。 避免 DLL 文件,日志文件泄露。

---
 Program.cs |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Program.cs b/Program.cs
index 17319e1..e16352d 100644
--- a/Program.cs
+++ b/Program.cs
@@ -1,9 +1,11 @@
 using Microsoft.Extensions.Hosting.WindowsServices;
+using APIGetway.Filter;
 
 var builder = WebApplication.CreateBuilder(new WebApplicationOptions
 {
     Args = args,
-    ContentRootPath = WindowsServiceHelpers.IsWindowsService() ? AppContext.BaseDirectory : null
+    // IIS 杩涚▼鍐呮墭绠℃椂宸ヤ綔鐩綍涓嶆槸绔欑偣鐩綍锛屽浐瀹氫负绋嬪簭鐩綍鎵嶈兘璇诲埌 appsettings.json
+    ContentRootPath = AppContext.BaseDirectory
 });
 
 builder.Services.AddWindowsService(options => options.ServiceName = "APIGetway");
@@ -14,10 +16,15 @@
 
 var app = builder.Build();
 
+// 鎷︽埅瀵� DLL/LOG 绛夋晱鎰熷悗缂�鐨勮闂紝鐩存帴杩斿洖 406锛堥渶鍦ㄩ潤鎬佹枃浠朵笌鍙嶅悜浠g悊涔嬪墠锛�
+app.UseFileExtensionFilter();
+
+app.UseUpstreamErrorPageFilter();
+
 app.UseDefaultFiles();
 app.UseStaticFiles();
 
-// YARP 杞彂锛氬尮閰� /API_NW/ 鍓嶇紑鐨勮姹傝浆鍙戝埌鍚庣
+// YARP 杞彂锛氭寜 appsettings.json 涓殑 Routes 瑙勫垯杞彂鍒板悗绔�
 app.MapReverseProxy();
 
 app.Run();

--
Gitblit v1.9.1