This commit is contained in:
zpc 2026-01-14 14:55:23 +08:00
parent e646d86004
commit 7c2420a00b
2 changed files with 25 additions and 20 deletions

1
.gitignore vendored
View File

@ -38,3 +38,4 @@ dist/
*.air
*.ipa
*.apk
/src/frontend/package-lock.json

View File

@ -1,9 +1,11 @@
using System.Text;
using System.Text;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using MilitaryTrainingManagement.Authorization;
using MilitaryTrainingManagement.Data;
using MilitaryTrainingManagement.Models.Enums;
@ -119,6 +121,7 @@ builder.Services.AddSwaggerGen(c =>
});
// 配置CORS
#if DEBUG
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAll", policy =>
@ -128,18 +131,19 @@ builder.Services.AddCors(options =>
.AllowAnyHeader();
});
});
#endif
var app = builder.Build();
// 配置HTTP请求管道
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
#if DEBUG
app.UseCors("AllowAll");
#endif
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();