-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
105 lines (56 loc) · 2.17 KB
/
Program.cs
File metadata and controls
105 lines (56 loc) · 2.17 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using sendbol_videoshop.Server.Models;
using sendbol_videoshop.Server.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Caching.StackExchangeRedis;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers()
.AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddHttpClient();
builder.Services.Configure<MongoVideoshopDatabaseSettings>(
builder.Configuration.GetSection("VideoshopDatabase"));
builder.Services.Configure<RedisVideoshopDatabaseSettings>(
builder.Configuration.GetSection("RedisConnection"));
builder.Services.AddSingleton<UsuariosService>();
builder.Services.AddSingleton<ProductosService>();
builder.Services.AddSingleton<CategoriasService>();
builder.Services.AddSingleton<EtiquetasService>();
builder.Services.AddSingleton<PlataformasService>();
builder.Services.AddSingleton<CountriesService>();
// Configurar Redis como almacenamiento de sesiones
builder.Services.AddStackExchangeRedisCache(options =>
{
options.Configuration = builder.Configuration.GetValue<string>("RedisConnection:ConnectionString");
});
builder.Services.AddSession(options =>
{
options.Cookie.Name = ".Sendbol.Session";
options.IdleTimeout = TimeSpan.FromHours(1);
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
});
// ...existing code...
var app = builder.Build();
#region Config. CORS
app.UseCors(options =>
options.WithOrigins("https://localhost:54993","http://localhost:54993", "http://0.0.0.0:54993", "https://26.211.167.41:54993", "https://192.168.137.1:54993", "http://192.168.137.1:54993")
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials() // <-- Esto es necesario
);
#endregion
app.UseDefaultFiles();
app.UseStaticFiles();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseSession(); // <-- Agrega esto aquí
app.UseAuthorization();
app.MapControllers();
app.MapFallbackToFile("/index.html");
app.Run();