mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Hardcode CORS.
This commit is contained in:
@@ -241,19 +241,14 @@ file class Program
|
||||
|
||||
builder.Services.AddScoped<TokenService, TokenService>();
|
||||
|
||||
// Read allowed CORS origins from configuration
|
||||
string[] allowedOrigins = builder.Configuration.GetSection("CORS:AllowedOrigins").Get<string[]>() ?? [];
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowFrontend",
|
||||
policy =>
|
||||
{
|
||||
// Check if wildcard is in the allowed origins
|
||||
if(allowedOrigins.Contains("*"))
|
||||
policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
|
||||
else if(allowedOrigins.Length > 0)
|
||||
policy.WithOrigins(allowedOrigins).AllowAnyHeader().AllowAnyMethod();
|
||||
policy.SetIsOriginAllowed(_ => true)
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user