|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
using AlarmService.API.Infrastructure; |
|
|
|
|
using Autofac; |
|
|
|
|
using Autofac.Extensions.DependencyInjection; |
|
|
|
|
using Common.Shared.Application.Core; |
|
|
|
|
using Common.Shared.DomainService; |
|
|
|
|
using Microsoft.OpenApi.Models; |
|
|
|
|
using NLog; |
|
|
|
|
@ -22,18 +23,20 @@ namespace AlarmService.API |
|
|
|
|
|
|
|
|
|
builder.Services.AddHttpContextAccessor(); |
|
|
|
|
builder.Services.AddHttpClient(); |
|
|
|
|
|
|
|
|
|
builder.Services.AddControllers(); |
|
|
|
|
builder.Services.AddSingleton(builder.Configuration); |
|
|
|
|
|
|
|
|
|
#region Cors |
|
|
|
|
|
|
|
|
|
var isconfig = builder.Configuration.GetSection("IdentityClientConfig").Get<CorsWithOrigins>(); |
|
|
|
|
builder.Services.AddCors(options => |
|
|
|
|
{ |
|
|
|
|
options.AddPolicy("_myAllowSpecificOrigins", |
|
|
|
|
builder => |
|
|
|
|
{ |
|
|
|
|
builder.AllowAnyOrigin() //允许所有源访问本API(开发环境设置) |
|
|
|
|
builder |
|
|
|
|
//.WithOrigins(isconfig.CorsOrigins) //被允许的来源,多个使用逗号分隔 |
|
|
|
|
.AllowAnyOrigin() //允许所有源访问本API(开发环境设置) |
|
|
|
|
.AllowAnyHeader() |
|
|
|
|
.AllowAnyMethod() |
|
|
|
|
.AllowCredentials() |
|
|
|
|
@ -112,9 +115,9 @@ namespace AlarmService.API |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
app.UseHttpsRedirection(); |
|
|
|
|
// app.UseHttpsRedirection(); |
|
|
|
|
|
|
|
|
|
app.UseAuthorization(); |
|
|
|
|
// app.UseAuthorization(); |
|
|
|
|
|
|
|
|
|
app.MapControllers(); |
|
|
|
|
app.MapGet("/healthz", () => Results.Ok("OK")); |
|
|
|
|
|