fix CORS
This commit is contained in:
@@ -22,6 +22,17 @@ ValidateConfiguration(config);
|
||||
|
||||
ConfigureJwtAuthentication(builder.Services, config);
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(policy =>
|
||||
{
|
||||
policy.WithOrigins(config.AllowedOrigins)
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
});
|
||||
});
|
||||
|
||||
builder.Services.AddAuthorization();
|
||||
|
||||
builder.Services.ConfigureHttpJsonOptions(options =>
|
||||
@@ -32,15 +43,7 @@ builder.Services.ConfigureHttpJsonOptions(options =>
|
||||
var app = builder.Build();
|
||||
Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true;
|
||||
|
||||
var currentConfig = app.Services.GetRequiredService<AppConfig>();
|
||||
|
||||
app.UseCors(policy =>
|
||||
{
|
||||
policy.WithOrigins(currentConfig.AllowedOrigins)
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
});
|
||||
app.UseCors();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user