cdk
2025-05-24 f72421dbf66b0097d44d26a7596b7238fa32ddbe
MESApplication/Startup.cs
@@ -92,27 +92,35 @@
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/error");
        }
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.InjectJavascript("");
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "API");
                c.DocExpansion(DocExpansion
                    .None);
                c.DocExpansion(DocExpansion.None);
                c.DefaultModelsExpandDepth(-1);
            });
        }
        app.UseCors(MyAllowSpecificOrigins); //添加这个
        // 添加根路径重定向中间件
        app.Use(async (context, next) =>
        {
            if (context.Request.Path == "/")
            {
                context.Response.Redirect("/swagger");
                return;
            }
            await next();
        });
        app.UseCors(MyAllowSpecificOrigins);
        app.UseRouting();
        app.UseAuthorization();
        app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        //////////////////////////
        ///////////////////////////
    }
}