diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs index be0fe985..9e08520e 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs @@ -56,14 +56,12 @@ namespace Yi.Abp.Web typeof(YiAbpApplicationModule), typeof(AbpAspNetCoreMultiTenancyModule), typeof(AbpAspNetCoreMvcModule), - typeof(AbpSwashbuckleModule), typeof(AbpAspNetCoreSerilogModule), typeof(AbpAuditingModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule), typeof(YiFrameworkAspNetCoreModule), typeof(YiFrameworkAspNetCoreAuthenticationOAuthModule), - typeof(YiFrameworkBackgroundWorkersHangfireModule), typeof(AbpAutofacModule) )] @@ -108,12 +106,9 @@ namespace Yi.Abp.Web //本地开发环境,可以禁用作业执行 if (host.IsDevelopment()) { - Configure (options => - { - options.IsEnabled = false; - }); + Configure(options => { options.IsEnabled = false; }); } - + //请求日志 Configure(options => { @@ -172,18 +167,27 @@ namespace Yi.Abp.Web { options.AddPolicy(DefaultCorsPolicyName, builder => { + var corsOrigins = configuration["App:CorsOrigins"]!; + builder - .WithOrigins( - configuration["App:CorsOrigins"]! + .WithAbpExposedHeaders() + .AllowAnyHeader() + .AllowAnyMethod(); + + if (corsOrigins == "*") + { + builder.AllowAnyOrigin(); + } + else + { + builder + .WithOrigins(corsOrigins .Split(";", StringSplitOptions.RemoveEmptyEntries) .Select(o => o.RemovePostFix("/")) - .ToArray() - ) - .WithAbpExposedHeaders() - .SetIsOriginAllowedToAllowWildcardSubdomains() - .AllowAnyHeader() - .AllowAnyMethod() - .AllowCredentials(); + .ToArray()) + .SetIsOriginAllowedToAllowWildcardSubdomains() + .AllowCredentials(); + } }); }); @@ -200,17 +204,17 @@ namespace Yi.Abp.Web //配置Hangfire定时任务存储,开启redis后,优先使用redis var redisConfiguration = configuration["Redis:Configuration"]; - context.Services.AddHangfire(config=> + context.Services.AddHangfire(config => { - var redisEnabled=configuration.GetSection("Redis").GetValue("IsEnabled"); + var redisEnabled = configuration.GetSection("Redis").GetValue("IsEnabled"); if (redisEnabled) { - var jobDb=configuration.GetSection("Redis").GetValue("JobDb"); + var jobDb = configuration.GetSection("Redis").GetValue("JobDb"); config.UseRedisStorage( ConnectionMultiplexer.Connect(redisConfiguration), new RedisStorageOptions() { - Db =jobDb, + Db = jobDb, InvisibilityTimeout = TimeSpan.FromHours(1), //JOB允许执行1小时 Prefix = "Yi:HangfireJob:" }).WithJobExpirationTimeout(TimeSpan.FromHours(1)); diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json b/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json index 744b05ba..95351b34 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json @@ -21,7 +21,7 @@ //应用启动 "App": { "SelfUrl": "http://*:19001", - "CorsOrigins": "http://localhost:19001;http://localhost:18000;vscode-file://vscode-app;https://web.chatboxai.app;capacitor://localhost;http://codegeex;https://yxai.chat" + "CorsOrigins": "*" }, //配置 "Settings": {