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