-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProgram.cs
40 lines (27 loc) · 1.01 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Microsoft.AspNetCore.Authentication.Negotiate;
using software_engineering_product_flowerpower.Models;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddEnvironmentVariables();
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<AppDbContext>(opt =>
opt.UseSqlServer(connectionString));
builder.Services.AddControllers();
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.WithOrigins("http://localhost:4200") // Adaugă URL-ul frontend-ului aici
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();
});
});
builder.Services.AddAuthentication(NegotiateDefaults.AuthenticationScheme)
.AddNegotiate();
var app = builder.Build();
app.UseHttpsRedirection();
app.UseCors(); // Asigură-te că UseCors este apelat înainte de UseAuthorization
app.UseAuthorization();
app.MapControllers();
app.Run();