From a8d0b99571b76ece78d27096606470169b15558e Mon Sep 17 00:00:00 2001 From: colesm Date: Thu, 20 Nov 2025 14:04:51 +0100 Subject: [PATCH] MAJ program pour liaison avec front --- PyroFetes/Program.cs | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/PyroFetes/Program.cs b/PyroFetes/Program.cs index 170f1b8..92fd763 100644 --- a/PyroFetes/Program.cs +++ b/PyroFetes/Program.cs @@ -1,29 +1,43 @@ -using API; using FastEndpoints; using FastEndpoints.Swagger; using PyroFetes; -using FastEndpoints.Security; - WebApplicationBuilder builder = WebApplication.CreateBuilder(args); -// On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet -builder.Services - .AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong") - .AddAuthorization() - .AddFastEndpoints() - .SwaggerDocument(); +//builder.Services +// .AddAuthenticationJwtBearer(s => s.SigningKey = "Thesecretusedtosigntokens") +// .AddAuthentication(); + +builder.Services.AddCors(options => + options.AddDefaultPolicy(policyBuilder => + policyBuilder.WithOrigins("http://localhost:61021") + .WithMethods("GET", "POST", "PUT", "PATCH", "DELETE") + .AllowAnyHeader() + ) +); +//builder.Services.AddAuthorization(); + + +builder.Services.AddFastEndpoints().SwaggerDocument( + options => + { + options.ShortSchemaNames = true; + }); -// On ajoute ici la configuration de la base de données builder.Services.AddDbContext(); -// On construit l'application en lui donnant vie WebApplication app = builder.Build(); -app.UseAuthentication() - .UseAuthorization() - .UseFastEndpoints() - .UseSwaggerGen(); +// app.UseAuthorization() +// .UseAuthentication(); +app.UseFastEndpoints(options => + { + options.Endpoints.RoutePrefix = "API"; + options.Endpoints.ShortNames = true; + } +).UseSwaggerGen(); app.UseHttpsRedirection(); +app.UseCors(); + app.Run(); \ No newline at end of file