using DS.Module.Core; using DS.Module.Core.Extensions; using DS.Module.Core.ServiceExtensions; using DS.WMS.GateWay; using Ocelot.DependencyInjection; using Ocelot.Middleware; var builder = WebApplication.CreateBuilder(args); IConfiguration configuration = new ConfigurationBuilder() .AddJsonFile("ocelot.json") .Build(); builder.Services.AddOcelot(configuration);////添加Ocelot服务 builder.Services.AddCorsInstall(); builder.WebHost.UseUrls("http://*:8002");//单个设置 var app = builder.Build(); //跨域 var policyName = AppSetting.Configuration["Cors:PolicyName"]; if (!policyName.IsNullOrEmpty()) { app.UseCors(policyName); //添加跨域中间件 } app.MapGet("/", () => "Hello World!"); app.UseMiddleware(); app.UseOcelot().Wait();//使用Ocelot中间件 app.Run();