Skip to content

Commit a601d72

Browse files
committedSep 4, 2024
Add CORS
1 parent e787438 commit a601d72

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

‎Program.cs

+14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
builder.Services.AddDbContext<AppDbContext>(options =>
77
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
88

9+
// Add CORS configuration
10+
builder.Services.AddCors(options =>
11+
{
12+
options.AddDefaultPolicy(policy =>
13+
{
14+
policy.AllowAnyOrigin()
15+
.AllowAnyHeader()
16+
.AllowAnyMethod();
17+
});
18+
});
19+
920
builder.Services.AddControllers();
1021
builder.Services.AddEndpointsApiExplorer();
1122
builder.Services.AddSwaggerGen();
@@ -35,6 +46,9 @@
3546
app.UseSwaggerUI();
3647
}
3748

49+
// Use CORS
50+
app.UseCors();
51+
3852
app.UseAuthorization();
3953

4054
app.MapControllers();

0 commit comments

Comments
 (0)
Please sign in to comment.