40 lines
904 B
C#
40 lines
904 B
C#
using CommunicationHub.Hubs;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSignalR();
|
|
builder.Services.AddCors((options) =>
|
|
{
|
|
options.AddPolicy("CorsPolicy", policy =>
|
|
{
|
|
policy.AllowAnyHeader()
|
|
.AllowAnyMethod()
|
|
.WithOrigins("http://localhost:3000")
|
|
.AllowCredentials();
|
|
});
|
|
});
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseRouting();
|
|
app.UseCors("CorsPolicy");
|
|
app.MapControllers();
|
|
app.MapHub<SeasonHub>("/hubs/season");
|
|
|
|
app.Run();
|
|
|