fix: add blazor-environment header to nginx for staging config
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 14m30s
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:
@@ -25,14 +25,12 @@ RUN rm -rf /usr/share/nginx/html/*
|
|||||||
# Copy published wwwroot (Blazor WASM output)
|
# Copy published wwwroot (Blazor WASM output)
|
||||||
COPY --from=build /app/publish/wwwroot .
|
COPY --from=build /app/publish/wwwroot .
|
||||||
|
|
||||||
# Configure nginx for SPA routing
|
# Copy entrypoint script that sets blazor-environment header
|
||||||
RUN echo 'server { \
|
COPY ["BackOffice/docker-entrypoint.sh", "/docker-entrypoint.sh"]
|
||||||
listen 80; \
|
RUN chmod +x /docker-entrypoint.sh
|
||||||
server_name _; \
|
|
||||||
location / { \
|
# Default Blazor environment (override via K8s env var BLAZOR_ENVIRONMENT)
|
||||||
root /usr/share/nginx/html; \
|
ENV BLAZOR_ENVIRONMENT=Staging
|
||||||
try_files $uri $uri/ /index.html; \
|
|
||||||
} \
|
|
||||||
}' > /etc/nginx/conf.d/default.conf
|
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
CMD ["/docker-entrypoint.sh"]
|
||||||
|
|||||||
@@ -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;'
|
||||||
Reference in New Issue
Block a user