fix(backend/cors): Configure CORS middleware order and add credentials support
- Moved UseCors() before UseAuthorization() in middleware pipeline - Added AllowCredentials() to AllowAll CORS policy - Added Development CORS policy with specific localhost origins (5173, 5174, 5175, 3000) Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
17ce0d1eb8
commit
3a94a8dbb9
1 changed files with 13 additions and 4 deletions
|
|
@ -95,7 +95,16 @@ try
|
|||
{
|
||||
builder.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
});
|
||||
|
||||
options.AddPolicy("Development", builder =>
|
||||
{
|
||||
builder.WithOrigins("http://localhost:5173", "http://localhost:5174", "http://localhost:5175", "http://localhost:3000")
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -245,6 +254,9 @@ try
|
|||
// Use exception middleware first (to catch all exceptions)
|
||||
app.UseExceptionMiddleware();
|
||||
|
||||
// Use CORS - must be early in the pipeline, before UseAuthorization
|
||||
app.UseCors("AllowAll");
|
||||
|
||||
// Serve static files (audio, etc.)
|
||||
app.UseStaticFiles();
|
||||
|
||||
|
|
@ -259,9 +271,6 @@ try
|
|||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
// Use CORS
|
||||
app.UseCors("AllowAll");
|
||||
|
||||
// Use Health Checks
|
||||
app.MapHealthChecks("/health");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue