|
|
@ -1,6 +1,8 @@ |
|
|
using Microsoft.AspNetCore.DataProtection; |
|
|
using Microsoft.AspNetCore.DataProtection; |
|
|
using StackExchange.Redis; |
|
|
using StackExchange.Redis; |
|
|
|
|
|
using Volo.Abp.AspNetCore.MultiTenancy; |
|
|
using Volo.Abp.Caching; |
|
|
using Volo.Abp.Caching; |
|
|
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
using Volo.Abp.Settings; |
|
|
using Volo.Abp.Settings; |
|
|
|
|
|
|
|
|
namespace Lion.AbpPro; |
|
|
namespace Lion.AbpPro; |
|
|
@ -23,6 +25,7 @@ public class AbpProSharedHostingMicroserviceModule : AbpModule |
|
|
ConfigureConsul(context, configuration); |
|
|
ConfigureConsul(context, configuration); |
|
|
ConfigAntiForgery(); |
|
|
ConfigAntiForgery(); |
|
|
ConfigureAbpExceptions(context); |
|
|
ConfigureAbpExceptions(context); |
|
|
|
|
|
ConfigureTenantResolvers(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -75,11 +78,11 @@ public class AbpProSharedHostingMicroserviceModule : AbpModule |
|
|
.Select(o => o.RemovePostFix("/")) |
|
|
.Select(o => o.RemovePostFix("/")) |
|
|
.ToArray() |
|
|
.ToArray() |
|
|
) |
|
|
) |
|
|
.WithAbpExposedHeaders() |
|
|
//.WithAbpExposedHeaders()
|
|
|
.SetIsOriginAllowedToAllowWildcardSubdomains() |
|
|
.SetIsOriginAllowedToAllowWildcardSubdomains() |
|
|
.AllowAnyHeader() |
|
|
.AllowAnyHeader() |
|
|
.AllowAnyMethod() |
|
|
.AllowAnyMethod() |
|
|
.AllowCredentials() |
|
|
//.AllowCredentials()
|
|
|
// https://www.cnblogs.com/JulianHuang/p/14225515.html
|
|
|
// https://www.cnblogs.com/JulianHuang/p/14225515.html
|
|
|
// https://learn.microsoft.com/zh-cn/aspnet/core/security/cors?view=aspnetcore-7.0
|
|
|
// https://learn.microsoft.com/zh-cn/aspnet/core/security/cors?view=aspnetcore-7.0
|
|
|
.SetPreflightMaxAge((TimeSpan.FromHours(24))); |
|
|
.SetPreflightMaxAge((TimeSpan.FromHours(24))); |
|
|
@ -118,4 +121,20 @@ public class AbpProSharedHostingMicroserviceModule : AbpModule |
|
|
// context.Services.AddHealthChecks().AddRedis(redisConnectionString).AddMySql(connectString);
|
|
|
// context.Services.AddHealthChecks().AddRedis(redisConnectionString).AddMySql(connectString);
|
|
|
context.Services.AddHealthChecks(); |
|
|
context.Services.AddHealthChecks(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 配置租户解析
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void ConfigureTenantResolvers() |
|
|
|
|
|
{ |
|
|
|
|
|
Configure<AbpTenantResolveOptions>(options => |
|
|
|
|
|
{ |
|
|
|
|
|
options.TenantResolvers.Clear(); |
|
|
|
|
|
// 只保留通过请求头解析租户
|
|
|
|
|
|
// options.TenantResolvers.Add(new QueryStringTenantResolveContributor());
|
|
|
|
|
|
// options.TenantResolvers.Add(new RouteTenantResolveContributor());
|
|
|
|
|
|
options.TenantResolvers.Add(new HeaderTenantResolveContributor()); |
|
|
|
|
|
// options.TenantResolvers.Add(new CookieTenantResolveContributor());
|
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |