73 lines
2.8 KiB
C#
73 lines
2.8 KiB
C#
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using Microsoft.OpenApi.Models;
|
|
using System.Text;
|
|
using uWine.Core.Domain.Repositories;
|
|
using uWine.Core.Infrastructure.Repository;
|
|
using uWine.Core.Infrastructure.Services;
|
|
|
|
namespace uWine.Api
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder = Builder.Servicies.AddAuthentiction(builder);
|
|
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
//builder.Services.AddSwaggerGen();
|
|
|
|
builder = Builder.Servicies.AddSwagger(builder);
|
|
builder = Builder.Servicies.AddRepository(builder);
|
|
builder = Builder.Servicies.AddServices(builder);
|
|
|
|
|
|
|
|
builder.Services.AddCors(options =>
|
|
{
|
|
//options.AddPolicy("AllowSpecificOrigin",
|
|
// policy =>
|
|
// {
|
|
// policy.WithOrigins("http://localhost:5000", "http://your_flutter_web_app_domain.com") // Sostituisci con l'URL della tua app Flutter (anche localhost se la testi in sviluppo)
|
|
// .AllowAnyMethod() // Permetti tutti i metodi (GET, POST, PUT, DELETE, OPTIONS, ecc.)
|
|
// .AllowAnyHeader(); // Permetti tutte le intestazioni, inclusa 'Authorization'
|
|
// // .AllowCredentials(); // Se la tua app Flutter invia credenziali (es. cookies, intestazioni di autorizzazione)
|
|
// });
|
|
|
|
// Puoi anche definire una policy più permissiva per lo sviluppo (NON USARE IN PRODUZIONE)
|
|
options.AddPolicy("AllowAll",
|
|
policy =>
|
|
{
|
|
policy.AllowAnyOrigin() // NON USARE IN PRODUZIONE: Permette richieste da qualsiasi origine
|
|
.AllowAnyMethod() // Permette tutti i metodi
|
|
.AllowAnyHeader(); // Permette tutte le intestazioni
|
|
// .AllowCredentials(); // Se necessario per le credenziali
|
|
});
|
|
});
|
|
|
|
//builder.Services.AddSingleton<MariaDbServerRepository>();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
//if (app.Environment.IsDevelopment())
|
|
//{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
//}
|
|
|
|
app.UseCors("AllowAll");
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|
|
}
|
|
}
|
|
}
|