46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using SPMS.Infrastructure;
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
|
|
{
|
|
WebRootPath = Environment.GetEnvironmentVariable("ASPNETCORE_WEBROOT")
|
|
?? "wwwroot"
|
|
});
|
|
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddOpenApi();
|
|
|
|
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
|
|
|
|
builder.Services.AddDbContext<AppDbContext>(options =>
|
|
options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.MapOpenApi();
|
|
}
|
|
var webRoot = app.Environment.WebRootPath;
|
|
Console.WriteLine($"[System] Web Root Path: {webRoot}"); // 로그에 경로 찍어보기
|
|
|
|
if (Directory.Exists(webRoot))
|
|
{
|
|
app.UseStaticFiles(); // 경로가 있으면 파일 서빙
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("[Error] Web root folder not found!");
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseRouting();
|
|
|
|
// [4] 요청 처리
|
|
app.MapControllers();
|
|
app.MapFallbackToFile("index.html");
|
|
|
|
app.Run(); |