111
This commit is contained in:
parent
e646d86004
commit
7c2420a00b
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -38,3 +38,4 @@ dist/
|
||||||
*.air
|
*.air
|
||||||
*.ipa
|
*.ipa
|
||||||
*.apk
|
*.apk
|
||||||
|
/src/frontend/package-lock.json
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
|
||||||
using MilitaryTrainingManagement.Authorization;
|
using MilitaryTrainingManagement.Authorization;
|
||||||
using MilitaryTrainingManagement.Data;
|
using MilitaryTrainingManagement.Data;
|
||||||
using MilitaryTrainingManagement.Models.Enums;
|
using MilitaryTrainingManagement.Models.Enums;
|
||||||
|
|
@ -119,6 +121,7 @@ builder.Services.AddSwaggerGen(c =>
|
||||||
});
|
});
|
||||||
|
|
||||||
// 配置CORS
|
// 配置CORS
|
||||||
|
#if DEBUG
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
options.AddPolicy("AllowAll", policy =>
|
options.AddPolicy("AllowAll", policy =>
|
||||||
|
|
@ -128,18 +131,19 @@ builder.Services.AddCors(options =>
|
||||||
.AllowAnyHeader();
|
.AllowAnyHeader();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// 配置HTTP请求管道
|
// 配置HTTP请求管道
|
||||||
if (app.Environment.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
}
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
#if DEBUG
|
||||||
app.UseCors("AllowAll");
|
app.UseCors("AllowAll");
|
||||||
|
#endif
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user