2022-12-02 15:03:34 +01:00

47 lines
1.1 KiB
C#

using Connected.Annotations;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Net.Http.Headers;
[assembly: MicroService(MicroServiceType.Sys)]
namespace Connected.Instance
{
[Priority(int.MaxValue)]
internal sealed class ServerStartup : Startup
{
protected override void OnConfigureServices(IServiceCollection services)
{
services.AddHttpContextAccessor();
services.AddSignalR();
services.AddHttpClient();
services.AddLogging();
services.AddAntiforgery();
services.AddCors((o) =>
{
o.AddDefaultPolicy(new Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy
{
IsOriginAllowed = (a) => { return true; },
Headers = { HeaderNames.ContentType, HeaderNames.ContentEncoding, HeaderNames.XRequestedWith, "x-signalr-user-agent" }
});
});
}
protected override void OnConfigure(WebApplication app)
{
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
app.UseHttpsRedirection();
}
app.UseCors();
app.UseRouting();
}
}
}