using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Server.Kestrel.Core; using Ocelot.DependencyInjection; using Ocelot.Middleware; var builder = WebApplication.CreateBuilder(args); // Add services to the container. #region Cors跨域 builder.Services.AddCors(options => { options.AddPolicy("all", builder => { builder.SetIsOriginAllowed(origin => true) //允许任何来源的主机访问 .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials();//指定处理cookie }); }); #endregion #region Body长度 builder.Services.Configure(options => { options.Limits.MaxRequestBodySize = null;//不做限制 }); builder.Services.Configure(options => { options.MaxRequestBodySize = null;//不做限制 }); builder.Services.Configure(x => { x.ValueLengthLimit = int.MaxValue; x.MultipartBodyLengthLimit = int.MaxValue; x.MultipartHeadersLengthLimit = int.MaxValue; }); #endregion builder.Services.AddOcelot(builder.Configuration); var app = builder.Build(); #region Cors跨域 app.UseCors("all"); #endregion app.UseWebSockets(); app.UseOcelot((build, cfg) => { build.BuildOcelotPipeline(cfg); }).Wait(); app.Run();