forked from sanchezvem/PyroFetes
42 lines
971 B
C#
42 lines
971 B
C#
using FastEndpoints;
|
|
using FastEndpoints.Swagger;
|
|
using PyroFetes;
|
|
|
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Services
|
|
builder.Services.AddCors(options =>
|
|
options.AddDefaultPolicy(policyBuilder =>
|
|
policyBuilder
|
|
.WithOrigins("http://localhost:4200") // mettre le port Angular exact
|
|
.WithMethods("GET", "POST", "PUT", "PATCH", "DELETE")
|
|
.AllowAnyHeader()
|
|
)
|
|
);
|
|
|
|
builder.Services.AddFastEndpoints().SwaggerDocument(options =>
|
|
{
|
|
options.ShortSchemaNames = true;
|
|
});
|
|
|
|
builder.Services.AddDbContext<PyroFetesDbContext>();
|
|
|
|
WebApplication app = builder.Build();
|
|
|
|
// Middleware
|
|
app.UseHttpsRedirection();
|
|
|
|
// CORS doit être avant les endpoints
|
|
app.UseCors();
|
|
|
|
// FastEndpoints et Swagger
|
|
app.UseFastEndpoints(options =>
|
|
{
|
|
options.Endpoints.RoutePrefix = "API";
|
|
options.Endpoints.ShortNames = true;
|
|
}).UseSwaggerGen();
|
|
|
|
// app.UseAuthorization();
|
|
// app.UseAuthentication();
|
|
|
|
app.Run(); |