From 5441ea196175b8a722632ad0b64ec8ff33209373 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期三, 11 十一月 2026 09:40:39 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/APIGetway
---
Program.cs | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/Program.cs b/Program.cs
index e16352d..3db8134 100644
--- a/Program.cs
+++ b/Program.cs
@@ -10,6 +10,14 @@
builder.Services.AddWindowsService(options => options.ServiceName = "APIGetway");
+builder.Services.AddCors(options =>
+{
+ options.AddPolicy("frontend-dev", policy => policy
+ .WithOrigins("http://192.168.0.102:32976") // 鎹㈡垚鍓嶇鐪熷疄鍦板潃+绔彛
+ .WithMethods("GET", "POST", "PUT", "DELETE")
+ .WithHeaders("Content-Type", "X-Username", "Authorization"));
+});
+
// YARP 鍙嶅悜浠g悊
builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
@@ -24,6 +32,10 @@
app.UseDefaultFiles();
app.UseStaticFiles();
+// 璺ㄥ煙涓棿浠讹細YARP 璺敱甯� CorsPolicy 鏃朵細寰�绔偣鍐� CORS 鍏冩暟鎹紝
+// 缂轰簡 UseCors 灏变細鍦ㄨ姹傛椂鎶� "contains CORS metadata, but a middleware was not found"
+app.UseCors();
+
// YARP 杞彂锛氭寜 appsettings.json 涓殑 Routes 瑙勫垯杞彂鍒板悗绔�
app.MapReverseProxy();
--
Gitblit v1.9.1