diff --git a/server/HoneyBox/src/HoneyBox.Api/Program.cs b/server/HoneyBox/src/HoneyBox.Api/Program.cs index 6f5bb910..ed10e664 100644 --- a/server/HoneyBox/src/HoneyBox.Api/Program.cs +++ b/server/HoneyBox/src/HoneyBox.Api/Program.cs @@ -1,5 +1,6 @@ -using Autofac; +using Autofac; using Autofac.Extensions.DependencyInjection; + using HoneyBox.Api.Filters; using HoneyBox.Core.Mappings; using HoneyBox.Infrastructure.Cache; @@ -7,11 +8,15 @@ using HoneyBox.Infrastructure.Modules; using HoneyBox.Model.Data; using HoneyBox.Model.Models.Auth; using HoneyBox.Model.Models.Payment; + using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; + using Scalar.AspNetCore; + using Serilog; + using System.Text; // 配置 Serilog @@ -143,20 +148,20 @@ try var app = builder.Build(); + + // 使用 OpenAPI 和 Scalar UI + app.MapOpenApi(); + app.MapScalarApiReference(options => + { + options.WithTitle("HoneyBox API"); + options.WithDefaultHttpClient(ScalarTarget.CSharp, ScalarClient.HttpClient); + }); + + // 添加根路径重定向到 Scalar 文档 + app.MapGet("/", () => Results.Redirect("/scalar/v1")); // 配置 HTTP 请求管道 if (app.Environment.IsDevelopment()) { - // 使用 OpenAPI 和 Scalar UI - app.MapOpenApi(); - app.MapScalarApiReference(options => - { - options.WithTitle("HoneyBox API"); - options.WithDefaultHttpClient(ScalarTarget.CSharp, ScalarClient.HttpClient); - }); - - // 添加根路径重定向到 Scalar 文档 - app.MapGet("/", () => Results.Redirect("/scalar/v1")); - // 仅开发环境启用 CORS,生产环境由 Nginx 配置 app.UseCors("Development"); }