39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using GrossesMitainesAPI.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddCors(options => {
|
|
options.AddPolicy(name: MyAllowSpecificOrigins,
|
|
policy => {
|
|
policy.WithOrigins("http://localhost:3000",
|
|
"http://localhost:3001")
|
|
.AllowAnyMethod();
|
|
});
|
|
});
|
|
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
builder.Services.AddDbContextFactory<InventoryContext>(options => { options.UseSqlServer("DefaultConnection"); });
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment()) {
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseCors(MyAllowSpecificOrigins);
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run(); |