Changeset bb02e3a for iknow-api/Program.cs
- Timestamp:
- 12/21/25 18:15:59 (9 months ago)
- Branches:
- master
- Children:
- 848c1c5
- Parents:
- aee2b88
- File:
-
- 1 edited
-
iknow-api/Program.cs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
iknow-api/Program.cs
raee2b88 rbb02e3a 9 9 10 10 var builder = WebApplication.CreateBuilder(args); 11 12 // Add CORS policy 13 builder.Services.AddCors(options => 14 { 15 options.AddPolicy("AllowFrontend", policy => 16 { 17 var allowedOrigins = builder.Configuration.GetSection("AllowedOrigins").Get<string[]>() 18 ?? new[] { "http://localhost:3000" }; 19 20 policy.WithOrigins(allowedOrigins) // Your frontend URL(s) 21 .AllowAnyHeader() 22 .AllowAnyMethod() 23 .AllowCredentials(); 24 }); 25 }); 26 11 27 builder.Services.AddAuthentication(options => 12 28 { … … 64 80 } 65 81 82 // Enable CORS - must be called before UseAuthentication and UseAuthorization 83 app.UseCors("AllowFrontend"); 84 66 85 app.UseHttpsRedirection(); 67 86 app.UseAuthentication(); // <-- must come BEFORE UseAuthorization
Note:
See TracChangeset
for help on using the changeset viewer.
