跨域配置添加暴露ExposedHeaders的功能

usertest
zhangxiaofeng 4 months ago
parent 15ab4211fb
commit 79970be082

@ -22,6 +22,7 @@ public static class CorsInstall
// var corsUrl = AppSetting.Configuration["Cors:Url"];
string policyName = AppSetting.app(new string[] { "Cors", "PolicyName" });
var corsUrl = AppSetting.app(new string[] { "Cors", "Url" });
var exposedHeaders = AppSetting.app(new string[] { "Cors", "ExposedHeaders" });
services.AddCors(c =>
{
@ -30,7 +31,8 @@ public static class CorsInstall
policy.WithOrigins(corsUrl
.Split(",", StringSplitOptions.RemoveEmptyEntries).ToArray())
//policy.WithOrigins("http://localhost:5001")//支持多个域名端口,注意端口号后不要带/斜杆比如localhost:8000/,是错的
.AllowAnyHeader().AllowAnyMethod().AllowCredentials(); //允许cookie;
.AllowAnyHeader().AllowAnyMethod().AllowCredentials()
.WithExposedHeaders(exposedHeaders.Split(",", StringSplitOptions.RemoveEmptyEntries)); //允许cookie;
});
});

@ -9,7 +9,8 @@
"Cors": {
"PolicyName": "WMSCore.API",
"Url": "http://localhost:3110,https://localhost:3110,http://localhost:3112,https://localhost:3112",
"IgnorePath": "swagger,login,tenantregister,linkattach,printtempfile,favicon,clientuserlogin,addbookingstatuslog,createbctaskjob,clientuserrefreshtoken"
"IgnorePath": "swagger,login,tenantregister,linkattach,printtempfile,favicon,clientuserlogin,addbookingstatuslog,createbctaskjob,clientuserrefreshtoken",
"ExposedHeaders": "Content-Disposition"
},
"JwtSettings": {
"Issuer": "vol.core.owner",

@ -14,7 +14,8 @@
},
"Cors": {
"PolicyName": "WMSCore.API",
"Url": "http://localhost:8000,http://localhost:5999,http://localhost:8088,http://localhost:5173,http://0.0.0.0:5999,http://0.0.0.0:9995,http://localhost:9995,http://rm-m5e06xxqpa68a68ry5o.mysql.rds.aliyuncs.com:9995,http://localhost:3000,https://localhost:3100,http://47.104.255.182:3100,http://47.104.255.182:3110,https://localhost:3110,http://localhost:8080,http://localhost:8081,http://localhost:8082,http://localhost:8083,http://localhost:8084"
"Url": "http://localhost:8000,http://localhost:5999,http://localhost:8088,http://localhost:5173,http://0.0.0.0:5999,http://0.0.0.0:9995,http://localhost:9995,http://rm-m5e06xxqpa68a68ry5o.mysql.rds.aliyuncs.com:9995,http://localhost:3000,https://localhost:3100,http://47.104.255.182:3100,http://47.104.255.182:3110,https://localhost:3110,http://localhost:8080,http://localhost:8081,http://localhost:8082,http://localhost:8083,http://localhost:8084",
"ExposedHeaders": "Content-Disposition"
},
"DBInfo": {
"DefaultDbConnId": "1288018625843826688",

Loading…
Cancel
Save