Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit aca78fa

Browse files
committed
Adicionadas e habilita políticas de CORS #2
1 parent 8962a30 commit aca78fa

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

DevStudyNotes.API/Program.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,28 @@
4242
o.IncludeXmlComments(xmlPath);
4343
});
4444

45+
// Políticas de CORS
46+
builder.Services.AddCors(options =>
47+
{
48+
options.AddDefaultPolicy(
49+
policy =>
50+
{
51+
policy.AllowAnyOrigin()
52+
.AllowAnyHeader()
53+
.AllowAnyMethod();
54+
}
55+
);
56+
options.AddPolicy("GitHub",
57+
policy =>
58+
{
59+
policy.WithOrigins("http://localhost:5000",
60+
"https://github.com/samuel-oldra")
61+
.AllowAnyHeader()
62+
.AllowAnyMethod();
63+
}
64+
);
65+
});
66+
4567
// Serilog
4668
builder.Host.ConfigureAppConfiguration((hostingContext, config) =>
4769
{
@@ -82,6 +104,11 @@
82104

83105
app.UseHttpsRedirection();
84106

107+
// Enable CORS
108+
app.UseCors();
109+
// app.UseCors("GitHub");
110+
// app.UseCors(o => o.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
111+
85112
app.UseAuthorization();
86113

87114
app.MapControllers();

0 commit comments

Comments
 (0)