forked from AcaMate/AcaMate_API
[♻️] 개발 FRONT 화면 테스트 3
This commit is contained in:
parent
4ef3f3dc23
commit
6580ac27b8
54
Program.cs
54
Program.cs
|
@ -24,6 +24,9 @@ using Back.Program.Services.V1;
|
|||
using Back.Program.Services.V1.Interfaces;
|
||||
|
||||
|
||||
Boolean isLocal = false;
|
||||
// 로컬 테스트 할 때는 이거 키고 아니면 끄기
|
||||
isLocal = true;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
@ -32,8 +35,6 @@ var builder = WebApplication.CreateBuilder(args);
|
|||
builder.Configuration.AddJsonFile("private/dbSetting.json", optional: true, reloadOnChange: true);
|
||||
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
// var connectionString = builder.Configuration.GetConnectionString("MariaDbConnection");
|
||||
// builder.Services.AddDbContext<AppDbContext>(options => options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
|
||||
builder.Services.AddDbContext<AppDbContext>(optionsAction: (serviceProvider, options) =>
|
||||
{
|
||||
var httpContextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
|
||||
|
@ -102,8 +103,6 @@ builder.Services.AddHttpClient<IPushService, PushService>(client =>
|
|||
{
|
||||
var config = builder.Configuration.GetSection("PushFileSetting").Get<PushFileSetting>();
|
||||
var handler = new HttpClientHandler();
|
||||
// using var reader = new StreamReader(config.p12PWPath, new UTF8Encoding(false));
|
||||
// var json = reader.ReadToEndAsync();
|
||||
// p12PWPath 파일에서 비밀번호 읽어오기 (예시: JSON {"Password": "비밀번호"})
|
||||
var json = File.ReadAllText(config.p12PWPath);
|
||||
var keys = JsonSerializer.Deserialize<Dictionary<string, string>>(json);
|
||||
|
@ -120,6 +119,7 @@ builder.Services.AddHostedService<PushBackgroundService>();
|
|||
|
||||
builder.Services.AddControllers();
|
||||
|
||||
// ==== SCOPED 으로 등록 할 서비스 ==== //
|
||||
// 여기다가 API 있는 컨트롤러들 AddScoped 하면 되는건가?
|
||||
builder.Services.AddScoped<JwtTokenService>();
|
||||
builder.Services.AddScoped<ILogRepository, LogRepository>();
|
||||
|
@ -161,40 +161,44 @@ builder.Services.AddCors(option =>
|
|||
// 로그 설정 부분
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Logging.AddConsole();
|
||||
if (builder.Environment.IsDevelopment()) {
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
builder.Logging.SetMinimumLevel(builder.Environment.IsDevelopment() ? LogLevel.Trace : LogLevel.Warning);
|
||||
|
||||
if (isLocal)
|
||||
{
|
||||
builder.WebHost.UseUrls("http://0.0.0.0:5144");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Warning);
|
||||
builder.WebHost.UseUrls(builder.Environment.IsDevelopment()? "http://0.0.0.0:7004":"http://0.0.0.0:7003");
|
||||
}
|
||||
|
||||
|
||||
builder.WebHost.UseUrls("http://0.0.0.0:7004");
|
||||
|
||||
|
||||
// 로컬 테스트 위한 부분 (올릴때는 꺼두기)
|
||||
// builder.WebHost.UseUrls("http://0.0.0.0:5144");
|
||||
|
||||
///// ===== builder 설정 부 ===== /////
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
string staticRoot;
|
||||
if (isLocal)
|
||||
{
|
||||
staticRoot = app.Environment.IsDevelopment() ?
|
||||
Path.Combine(Directory.GetCurrentDirectory(), "publish", "debug", "wwwroot") :
|
||||
Path.Combine(Directory.GetCurrentDirectory(), "publish", "release", "wwwroot") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
staticRoot = app.Environment.IsDevelopment() ?
|
||||
"/src/publish/debug/wwwroot" : "/src/publish/release/wwwroot" ;
|
||||
}
|
||||
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
// app.UseSwagger();
|
||||
// app.UseSwaggerUI();
|
||||
app.UseCustomSwaggerUI();
|
||||
app.UseDeveloperExceptionPage(); // 좀더 자세한 예외 정보 제공
|
||||
staticRoot = Path.Combine(Directory.GetCurrentDirectory(), "publish", "debug", "wwwroot");
|
||||
}
|
||||
else
|
||||
{
|
||||
app.UseExceptionHandler("/error");
|
||||
app.UseHsts();
|
||||
staticRoot = Path.Combine(Directory.GetCurrentDirectory(), "publish", "release", "wwwroot");
|
||||
}
|
||||
|
||||
// 로컬 테스트 위한 부분 (올릴떄는 켜두기)
|
||||
|
@ -203,12 +207,8 @@ app.UseHttpsRedirection();
|
|||
//예외처리 미들웨어 부분
|
||||
app.UseMiddleware<ExceptionMiddleware>();
|
||||
// 헤더 미들웨어 부분
|
||||
app.UseMiddleware<APIHeaderMiddleware>(
|
||||
(object)new string[] { "iOS_AM_Connect_Key", "And_AM_Connect_Key", "Web_AM_Connect_Key" }
|
||||
);
|
||||
|
||||
// app.UseBlazorFrameworkFiles();
|
||||
// app.UseStaticFiles();
|
||||
app.UseMiddleware<APIHeaderMiddleware>
|
||||
((object)new string[] { "iOS_AM_Connect_Key", "And_AM_Connect_Key", "Web_AM_Connect_Key" });
|
||||
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
|
@ -216,9 +216,6 @@ app.UseStaticFiles(new StaticFileOptions
|
|||
RequestPath = ""
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
app.UseRouting();
|
||||
app.UseCors("CorsPolicy");
|
||||
app.UseAuthorization();
|
||||
|
@ -228,10 +225,7 @@ app.UseWebSockets();
|
|||
app.UseEndpoints(end =>
|
||||
{
|
||||
ControllerEndpointRouteBuilderExtensions.MapControllers(end);
|
||||
|
||||
// 프론트 테스트 위한 부분
|
||||
end.MapFallbackToFile("index.html");
|
||||
|
||||
end.MapHub<ChatHub>("/chatHub");
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user