fix: inject GwUrl into appsettings at container startup
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 15m1s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 15m1s
The blazor-environment header is stripped by the Blazor WASM service worker cache, causing Blazor to fall back to Production environment and load appsettings.Production.json (GwUrl=https://cms.kbs1.ir). Fix: use sed in docker-entrypoint.sh to replace GwUrl in ALL appsettings*.json files at container startup with the GW_URL env var. Default GW_URL=https://cms.se.kbs1.ir for staging deployment.
This commit is contained in:
@@ -31,6 +31,8 @@ RUN chmod +x /docker-entrypoint.sh
|
||||
|
||||
# Default Blazor environment (override via K8s env var BLAZOR_ENVIRONMENT)
|
||||
ENV BLAZOR_ENVIRONMENT=Staging
|
||||
# Default gateway URL for gRPC calls (injected into appsettings at startup)
|
||||
ENV GW_URL=https://cms.se.kbs1.ir
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["/docker-entrypoint.sh"]
|
||||
|
||||
@@ -15,4 +15,16 @@ server {
|
||||
}
|
||||
NGINX_CONF
|
||||
|
||||
# Inject GW_URL into all appsettings JSON files
|
||||
# This overrides GwUrl regardless of which environment Blazor detects,
|
||||
# which is critical because the service worker cache strips the
|
||||
# blazor-environment header and Blazor falls back to Production.
|
||||
WWWROOT="/usr/share/nginx/html"
|
||||
if [ -n "$GW_URL" ]; then
|
||||
echo "[entrypoint] Setting GwUrl to $GW_URL in all appsettings files"
|
||||
for f in "$WWWROOT"/appsettings*.json; do
|
||||
[ -f "$f" ] && sed -i "s|\"GwUrl\":\s*\"[^\"]*\"|\"GwUrl\": \"$GW_URL\"|g" "$f"
|
||||
done
|
||||
fi
|
||||
|
||||
exec nginx -g 'daemon off;'
|
||||
|
||||
Reference in New Issue
Block a user