mirror of
https://github.com/QuotifyTeam/QuotifyBE.git
synced 2025-12-16 14:20:06 +01:00
feat: experimental cors support
This commit is contained in:
16
Program.cs
16
Program.cs
@@ -21,6 +21,22 @@ var JwtSecret = builder.Configuration["JwtSecret"]
|
||||
var DomainName = builder.Configuration["DomainName"]
|
||||
?? throw new InvalidOperationException("Domain name is not configured!!! Please configure DomainName in appsettings.json!");
|
||||
|
||||
var CorsOrigins = builder.Configuration.GetSection("CorsOrigins").Get<List<string>>()
|
||||
?? throw new InvalidOperationException("CORS is not configured!!! Please configure CorsOrigins in appsettings.json!");
|
||||
|
||||
// Add default CORS policy
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
|
||||
options.AddDefaultPolicy(
|
||||
policy =>
|
||||
{
|
||||
policy
|
||||
.WithOrigins(CorsOrigins.ToArray())
|
||||
.AllowAnyHeader(); // this might not be the greatest idea
|
||||
});
|
||||
});
|
||||
|
||||
// Configure JWT authentication
|
||||
// https://medium.com/@solomongetachew112/jwt-authentication-in-net-8-a-complete-guide-for-secure-and-scalable-applications-6281e5e8667c
|
||||
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
|
||||
Reference in New Issue
Block a user