fix: add blazor-environment header to nginx for staging config
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 14m30s

BackOffice WASM app defaulted to Production environment because
nginx didn't set the blazor-environment response header. This caused
the app to load appsettings.Production.json (GwUrl=https://cms.kbs1.ir)
instead of appsettings.Staging.json (GwUrl=https://cms.se.kbs1.ir),
resulting in 401 gRPC errors on the login page.

- Add docker-entrypoint.sh that generates nginx config with blazor-environment header
- Default BLAZOR_ENVIRONMENT=Staging (configurable via K8s env var)
- This ensures the WASM app loads the correct staging configuration
This commit is contained in:
masoodafar-web
2026-03-15 00:19:04 +03:30
parent 76dbee7d41
commit 1ef5edf939
2 changed files with 25 additions and 9 deletions
+7 -9
View File
@@ -25,14 +25,12 @@ RUN rm -rf /usr/share/nginx/html/*
# Copy published wwwroot (Blazor WASM output)
COPY --from=build /app/publish/wwwroot .
# Configure nginx for SPA routing
RUN echo 'server { \
listen 80; \
server_name _; \
location / { \
root /usr/share/nginx/html; \
try_files $uri $uri/ /index.html; \
} \
}' > /etc/nginx/conf.d/default.conf
# Copy entrypoint script that sets blazor-environment header
COPY ["BackOffice/docker-entrypoint.sh", "/docker-entrypoint.sh"]
RUN chmod +x /docker-entrypoint.sh
# Default Blazor environment (override via K8s env var BLAZOR_ENVIRONMENT)
ENV BLAZOR_ENVIRONMENT=Staging
EXPOSE 80
CMD ["/docker-entrypoint.sh"]
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
# Generate nginx config with blazor-environment header
# BLAZOR_ENVIRONMENT defaults to "Staging" if not set
BLAZOR_ENV="${BLAZOR_ENVIRONMENT:-Staging}"
cat > /etc/nginx/conf.d/default.conf <<NGINX_CONF
server {
listen 80;
server_name _;
location / {
root /usr/share/nginx/html;
try_files \$uri \$uri/ /index.html;
add_header blazor-environment $BLAZOR_ENV;
}
}
NGINX_CONF
exec nginx -g 'daemon off;'