{
var builder = WebApplication.CreateBuilder(args);
var config = builder.Configuration;
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(
builder =>
{
builder.AllowAnyOrigin().WithOrigins("http://localhost:8081").AllowAnyHeader().AllowAnyMethod();
});
});
builder.Services.AddControllers();
builder.Services.AddHttpClient(GEOLOCATION_HTTPCLIENT_NAME, client =>
{
var geolocationApiKey = config.GetSection("Tokens")["GeolocationApi"];
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Token", geolocationApiKey);
});
builder.Services
.AddRouteAnalyzer()
.AddRentInHendApiServices()
.AddModelVlidators()
.AddNativeServices()
.AddApiRepositrories()
.AddDbContexts(config)
.ConfigAutoMapper()
.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options =>
{
options.LoginPath = new PathString("/User/Login");
options.LogoutPath = new PathString("/User/Logout");
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseCors(b => b.AllowAnyOrigin().WithOrigins("http://localhost:8081").AllowAnyHeader().AllowAnyMethod());
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
app.Run();
}
Вместо ёбки, просто сделай dev.твой_домен/ для разработки
Обсуждают сегодня