Update CORS to make it run on localhost

This commit is contained in:
Stedoss 2023-12-07 01:08:37 +00:00
parent 2732794750
commit 025983bd21
2 changed files with 11 additions and 3 deletions

View File

@ -16,6 +16,7 @@ To run in development mode, you will need:
### Running locally
To run in development mode, run:
```sh
cd YPS.Beer/
dotnet run
```

View File

@ -29,7 +29,10 @@ builder.Services.AddAuthentication(IdentityConstants.ApplicationScheme)
.AddApplicationCookie();
builder.Services.AddAuthorizationBuilder();
builder.Services.AddCors();
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy => policy.WithOrigins("http://localhost:3000").AllowAnyMethod().AllowAnyHeader().AllowCredentials());
});
var app = builder.Build();
@ -37,12 +40,16 @@ if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
app.UseCors(cors => cors.AllowAnyHeader().AllowAnyMethod().SetIsOriginAllowed(_ => true).AllowCredentials());
}
app.UseRouting();
app.UseHttpsRedirection();
app.UseCors();
app.UseAuthorization();
app.MapControllers();
app.MapIdentityApi<User>();