You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.2 KiB
C#

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<KestrelServerOptions>(options =>
{
options.Limits.MaxRequestBodySize = null;//不做限制
});
builder.Services.Configure<IISServerOptions>(options =>
{
options.MaxRequestBodySize = null;//不做限制
});
builder.Services.Configure<FormOptions>(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();