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