Added cors to API

This commit is contained in:
2026-09-11 14:34:17 +02:00
parent 99ab5b2ce6
commit b99ebf657c
6 changed files with 6900 additions and 787 deletions
+6 -2
View File
@@ -91,6 +91,9 @@ builder.Services.AddOpenApi(options =>
});
});
builder.Services.AddCors(options => options.AddPolicy("AllowFrontend", policy =>
policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().AllowCredentials()));
var app = builder.Build();
var schedulerFactory = app.Services.GetRequiredService<ISchedulerFactory>();
@@ -104,6 +107,7 @@ app.UseHttpsRedirection();
app.UseRouting();
app.UseOutputCache();
app.UseCors("AllowFrontend");
app.UseAuthentication();
app.UseAuthorization();
@@ -114,7 +118,7 @@ ApiVersionSet versionSet = app.NewApiVersionSet("v1")
var versionGroups = new Dictionary<int, RouteGroupBuilder>
{
{
{
1, app.MapGroup("v{version:apiVersion}").WithApiVersionSet(versionSet)
.RequireAuthorization("ApiScope").AddEndpointFilter<ActiveUserFilter>()
}
@@ -143,7 +147,7 @@ foreach (var description in app.DescribeApiVersions().OrderByDescending(o => o.A
app.MapScalarApiReference($"/openapi/{description.GroupName}", (options, context) =>
{
options.AddServer(new ScalarServer($"https://{context.Request.Host}"));
options.WithOpenApiRoutePattern($"/openapi/{description.GroupName}.json");
options.WithOpenApiRoutePattern($"/openapi/{description.GroupName}.json");
options.WithTheme(ScalarTheme.DeepSpace);
options.Agent = new ScalarAgentOptions { Disabled = true };
options.AddPreferredSecuritySchemes("OAuth2")
File diff suppressed because it is too large Load Diff
+6 -5
View File
@@ -13,7 +13,7 @@
"dependencies": {
"@google/genai": "^2.4.0",
"@hookform/resolvers": "^5.9.1",
"@tailwindcss/vite": "^4.1.14",
"@tailwindcss/vite": "^4.3.3",
"@tanstack/react-query": "^5.102.8",
"@vitejs/plugin-react": "^5.0.4",
"axios": "^1.20.0",
@@ -30,13 +30,14 @@
"zod": "^4.5.4"
},
"devDependencies": {
"@types/express": "^4.17.21",
"@types/node": "^22.14.0",
"autoprefixer": "^10.4.21",
"autoprefixer": "^10.5.6",
"esbuild": "^0.25.0",
"tailwindcss": "^4.1.14",
"postcss": "^8.5.28",
"tailwindcss": "^4.3.3",
"tsx": "^4.21.0",
"typescript": "~5.8.2",
"vite": "^6.2.3",
"@types/express": "^4.17.21"
"vite": "^6.2.3"
}
}
+2 -2
View File
@@ -17,8 +17,8 @@ export interface AppConfig {
export const defaultSecuritySettings: SecuritySettings = {
Authority: (import.meta.env.VITE_OIDC_AUTHORITY as string) || 'https://sts.security.khongisa.co.za',
Audience: (import.meta.env.VITE_OIDC_AUDIENCE as string) || 'pfm-api-dev',
ClientId: (import.meta.env.VITE_OIDC_CLIENT_ID as string) || 'pfm-scalar-dev',
ClientSecret: (import.meta.env.VITE_OIDC_CLIENT_SECRET as string) || 'secret_71f88570a46eb22eb5270b47f69e3332c84d8db85d008f0276cb7431c8872d27',
ClientId: (import.meta.env.VITE_OIDC_CLIENT_ID as string) || 'pfm-admin-dev',
ClientSecret: (import.meta.env.VITE_OIDC_CLIENT_SECRET as string) || 'secret_dcaeaa28097d9ba5b06ec324d9eac9d9c81de96e0a203cf2c6154c6dd7c89e94',
};
export const defaultApiSettings: ApiSettings = {
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff