From 35702d2c6675faece6e97f0620d2a11e847a5075 Mon Sep 17 00:00:00 2001 From: Jonas Date: Sat, 8 Feb 2025 20:31:31 +0100 Subject: [PATCH] Added Cors --- noteApi/Program.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/noteApi/Program.cs b/noteApi/Program.cs index 807c358..c97023b 100644 --- a/noteApi/Program.cs +++ b/noteApi/Program.cs @@ -78,16 +78,14 @@ builder.Services.AddAuthentication(options => }); -var MyAllowSpecificOrigins = "_myAllowSpecificOrigins"; - builder.Services.AddCors(options => { - options.AddPolicy(name: MyAllowSpecificOrigins, + options.AddPolicy("AllowAll", policy => { - policy.WithOrigins("http://localhost:5173", "http://localhost:7212") - .AllowAnyHeader() - .AllowAnyMethod(); + policy.AllowAnyOrigin() + .AllowAnyHeader() + .AllowAnyMethod(); }); }); @@ -103,7 +101,7 @@ if (app.Environment.IsDevelopment()) app.UseSwaggerUI(); } -app.UseCors(MyAllowSpecificOrigins); +app.UseCors("AllowAll"); app.UseAuthentication(); app.UseAuthorization();