Update CORS to make it run on localhost
This commit is contained in:
parent
2732794750
commit
025983bd21
@ -16,6 +16,7 @@ To run in development mode, you will need:
|
|||||||
### Running locally
|
### Running locally
|
||||||
To run in development mode, run:
|
To run in development mode, run:
|
||||||
```sh
|
```sh
|
||||||
|
cd YPS.Beer/
|
||||||
dotnet run
|
dotnet run
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -29,7 +29,10 @@ builder.Services.AddAuthentication(IdentityConstants.ApplicationScheme)
|
|||||||
.AddApplicationCookie();
|
.AddApplicationCookie();
|
||||||
builder.Services.AddAuthorizationBuilder();
|
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();
|
var app = builder.Build();
|
||||||
|
|
||||||
@ -37,12 +40,16 @@ if (app.Environment.IsDevelopment())
|
|||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
|
|
||||||
app.UseCors(cors => cors.AllowAnyHeader().AllowAnyMethod().SetIsOriginAllowed(_ => true).AllowCredentials());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.UseRouting();
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseCors();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
app.MapIdentityApi<User>();
|
app.MapIdentityApi<User>();
|
||||||
|
Loading…
Reference in New Issue
Block a user