|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
using System; |
|
|
|
|
using System.Net; |
|
|
|
|
using System.Text.Json; |
|
|
|
|
using Microsoft.AspNetCore.Builder; |
|
|
|
|
using Microsoft.AspNetCore.Hosting; |
|
|
|
|
using Microsoft.AspNetCore.HttpOverrides; |
|
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
|
using Microsoft.Extensions.Hosting; |
|
|
|
@ -18,6 +21,11 @@ namespace Server {
|
|
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container. |
|
|
|
|
public void ConfigureServices(IServiceCollection services) { |
|
|
|
|
if ((Environment.GetEnvironmentVariable("INSIDE_DOCKER") ?? "").Length > 0) { |
|
|
|
|
services.Configure<ForwardedHeadersOptions>(options => { |
|
|
|
|
options.KnownProxies.Add(Dns.GetHostAddresses("host.docker.internal")[0]); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
services.AddSingleton<IDataManager, DataManager>(); |
|
|
|
|
services.AddSingleton<IDatabase, Database>(); |
|
|
|
|
services.AddSingleton<NodaTime.IDateTimeZoneProvider>(NodaTime.DateTimeZoneProviders.Tzdb); |
|
|
|
@ -34,6 +42,10 @@ namespace Server {
|
|
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. |
|
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { |
|
|
|
|
app.UseForwardedHeaders(new ForwardedHeadersOptions { |
|
|
|
|
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (env.IsDevelopment()) { |
|
|
|
|
app.UseDeveloperExceptionPage(); |
|
|
|
|
app.UseSwagger(); |
|
|
|
|