AcaMate_Web/Program.cs
2025-07-03 21:16:55 +09:00

61 lines
1.7 KiB
C#

using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Front;
using Front.Program.Services;
using Front.Program.ViewModels;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
// 로컬 또는 Dev 환경인지 확인
var currentUri = new Uri(builder.HostEnvironment.BaseAddress);
bool isLocal = currentUri.Host == "0.0.0.0" || currentUri.Port.ToString() == "5144";
bool isDev = isLocal ||
builder.HostEnvironment.IsDevelopment();
Uri CheckLocal()
{
if (isLocal)
return new Uri("http://0.0.0.0:5144");
else
return builder.HostEnvironment.IsDevelopment() ?
new Uri("https://devacamate.ipstein.myds.me") :
new Uri("https://acamate.ipstein.myds.me");
}
LoggerService.Initialize(isDev);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
// 설정 파일 로드
builder.Configuration.AddJsonFile($"appsettings.{builder.HostEnvironment.Environment}.json", optional: true);
builder.Services.AddScoped(sp => //new HttpClient
{
var config = builder.Configuration;
var http = new HttpClient
{
BaseAddress = CheckLocal()
};
return http;
});
// SCOPED 으로 등록된 서비스는 DI 컨테이너에 등록된 서비스의 인스턴스를 사용합니다.
builder.Services.AddScoped<APIService>();
builder.Services.AddScoped<SecureService>();
builder.Services.AddScoped<StorageService>();
builder.Services.AddScoped<QueryParamService>();
builder.Services.AddScoped<LoadingService>();
builder.Services.AddSingleton<UserStateService>();
// builder.Services.AddSingleton<LoggerService>(sp
await builder.Build().RunAsync();