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(); } } }