Compare commits

..

No commits in common. "80664784470ad1422a0a92fbf4462b519f9cd66b" and "6abff69bcb0e429158b037ecb2977097d12dac71" have entirely different histories.

2 changed files with 11 additions and 4 deletions

View File

@ -1,5 +1,3 @@
# syntax=docker/dockerfile:1.7-labs
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build1
WORKDIR /src
@ -16,7 +14,8 @@ WORKDIR /src
COPY ./Groceries.sln ./
COPY ./Directory.Build.props ./
COPY --parents */*.csproj .
COPY */*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p ${file%.*} && mv $file ${file%.*}; done
RUN dotnet restore
COPY . ./
@ -31,7 +30,6 @@ COPY --from=build2 /src/Groceries/config.ini /config/
RUN apk add --no-cache icu-libs tzdata
ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
ENV ASPNETCORE_HTTP_PORTS=80
ENV DOTNET_ENABLEDIAGNOSTICS=0
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false

View File

@ -1,6 +1,7 @@
using DbUp;
using Groceries.Data;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
@ -28,6 +29,13 @@ if (!dbUpgradeResult.Successful)
return -1;
}
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.All;
options.KnownNetworks.Clear();
options.KnownProxies.Clear();
});
var dataProtection = builder.Services.AddDataProtection();
if (env.IsProduction())
{
@ -51,6 +59,7 @@ builder.Services.AddDbContextPool<AppDbContext>(options => options
var app = builder.Build();
app.UseForwardedHeaders();
app.UseStaticFiles();
app.UseRouting();
app.UseSession();