kljhlkjhljh

This commit is contained in:
Hukuta committed 2026-05-18 06:53:33 +09:00
1 parent 3e8e7381e5
commit 47fb655a96
6 files changed
+38 -13

No files matched your search

+27 -7
View File
@@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Scalar.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddScoped<IPrinterService, PrinterService>();
@@ -16,42 +17,61 @@ builder.Services.AddScoped<IManufacturerService, ManufacturerService>();
builder.Services.AddScoped<IArticleService, ArticleService>();
builder.Services.AddSingleton<ISnmpService, SnmpService>();
builder.Services.AddHostedService<BackgroundApiService>();
// CORS
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAll", policy =>
{
policy.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
policy
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
});
});
// Слушаем все сетевые интерфейсы
builder.WebHost.UseUrls(
"http://192.168.0.26:5917"
);
builder.Services.AddOpenApi();
builder.Services.AddDbContext<AppDbContext>(options =>
{
options.UseSqlite(builder.Configuration.GetConnectionString("DevSQL"));
options.UseSqlite(
builder.Configuration.GetConnectionString("DevSQL"));
});
var app = builder.Build();
app.MapControllers();
// ПОРЯДОК ВАЖЕН!
app.UseRouting();
// CORS должен быть ДО MapControllers()
app.UseCors("AllowAll");
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
app.MapScalarApiReference(options =>
{
options.HideSearch = true;
options.HideModels = true;
options.Layout = ScalarLayout.Modern;
options.DefaultOpenAllTags = false;
options.Agent = new ScalarAgentOptions()
options.Agent = new ScalarAgentOptions
{
Disabled = true,
Disabled = true
};
options.Title = "CartriX API Documentation";
options.Theme = ScalarTheme.DeepSpace;
});
}
app.Run();
// Контроллеры должны быть ПОСЛЕ UseCors()
app.MapControllers();
app.Run();
+2 -2
View File
@@ -3,7 +3,7 @@
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:5197/scalar",
"launchUrl": "http://0.0.0.0:5197/scalar",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
@@ -13,7 +13,7 @@
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "https://localhost:7209/scalar",
"launchUrl": "https://0.0.0.0:7209/scalar",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},