Compare commits
No commits in common. "24d2ebe466e92a3c2579cd1ca051873180c2d3c8" and "ddce0f5ae0b399b5c530eda4b5df1c5bc8d9efb7" have entirely different histories.
24d2ebe466
...
ddce0f5ae0
54
Program.cs
54
Program.cs
|
@ -24,9 +24,6 @@ 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);
|
||||||
|
|
||||||
|
@ -35,6 +32,8 @@ 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>();
|
||||||
|
@ -103,6 +102,8 @@ 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);
|
||||||
|
@ -119,7 +120,6 @@ 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,44 +161,40 @@ builder.Services.AddCors(option =>
|
||||||
// 로그 설정 부분
|
// 로그 설정 부분
|
||||||
builder.Logging.ClearProviders();
|
builder.Logging.ClearProviders();
|
||||||
builder.Logging.AddConsole();
|
builder.Logging.AddConsole();
|
||||||
builder.Logging.SetMinimumLevel(builder.Environment.IsDevelopment() ? LogLevel.Trace : LogLevel.Warning);
|
if (builder.Environment.IsDevelopment()) {
|
||||||
|
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||||
if (isLocal)
|
|
||||||
{
|
|
||||||
builder.WebHost.UseUrls("http://0.0.0.0:5144");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
builder.WebHost.UseUrls(builder.Environment.IsDevelopment()? "http://0.0.0.0:7004":"http://0.0.0.0:7003");
|
builder.Logging.SetMinimumLevel(LogLevel.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 로컬 테스트 위한 부분 (올릴떄는 켜두기)
|
// 로컬 테스트 위한 부분 (올릴떄는 켜두기)
|
||||||
|
@ -207,8 +203,12 @@ 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,6 +216,9 @@ app.UseStaticFiles(new StaticFileOptions
|
||||||
RequestPath = ""
|
RequestPath = ""
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
app.UseCors("CorsPolicy");
|
app.UseCors("CorsPolicy");
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
@ -225,7 +228,10 @@ 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