Admin api changes

This commit is contained in:
Rory&
2025-10-14 09:07:55 +02:00
parent 05285114cd
commit 58d92080d5
28 changed files with 1276 additions and 33 deletions

View File

@@ -45,20 +45,29 @@ builder.Services.AddRequestTimeouts(x => {
}
};
});
builder.Services.AddCors(options => {
options.AddPolicy(
"Open",
policy => policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
});
// builder.Services.AddCors(options => {
// options.AddPolicy(
// "Open",
// policy => policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
// });
var app = builder.Build();
app.Use((context, next) => {
context.Response.Headers["Access-Control-Allow-Origin"] = "*";
context.Response.Headers["Access-Control-Allow-Methods"] = "GET, POST, PUT, DELETE, OPTIONS";
context.Response.Headers["Access-Control-Allow-Headers"] = "*, Authorization";
if (context.Request.Method == "OPTIONS") {
context.Response.StatusCode = 200;
return Task.CompletedTask;
}
return next();
});
app.UsePathBase("/_spacebar/admin");
app.UseCors("Open");
// app.UseCors("Open");
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment()) {
app.MapOpenApi();
}
app.MapOpenApi();
app.UseMiddleware<AuthenticationMiddleware>();
app.UseAuthorization();