@@ -197,14 +197,17 @@ namespace YhCore.WebApi
|
||||
c.SwaggerEndpoint("/swagger/oapi/swagger.json", "OApi");
|
||||
});
|
||||
|
||||
// 静态文件(wwwroot):承载同源调试页面(如 cookie-test.html)。
|
||||
// 放在 UseRouting 之前:静态文件请求直接短路,不进入 SSO/认证管道。
|
||||
app.UseStaticFiles();
|
||||
|
||||
// 管道顺序:先路由,再认证;CAS 回调必须在认证阶段消费 ticket 并写入 Cookie。
|
||||
app.UseRouting();
|
||||
|
||||
// CORS 中间件必须位于 UseRouting 之后、UseEndpoints 之前(endpoint-aware 模式):
|
||||
// 否则带 [EnableCors] 元数据的控制器端点执行时抛 InvalidOperationException
|
||||
// "contains CORS metadata, but a middleware was not found that supports CORS"(曾导致 GetUserInfo code6)。
|
||||
// 对应 Java @CrossOrigin(originPatterns={"*"}, allowCredentials="true")
|
||||
app.UseCors("default");
|
||||
app.UseCors("AllowSpecificOrigin");
|
||||
|
||||
// 启用 ASP.NET Core Session(需在 UseEndpoints 之前、且在使用 Session 的组件之前注册)。
|
||||
// 仅 Logout 真正读写;其余请求不触碰 Session,不会额外下发 .AspNetCore.Session Cookie。
|
||||
|
||||
Reference in New Issue
Block a user