Skip to content

Commit 9579ae2

Browse files
committed
Prevents caching of runtime config
Ensures environment-based file reloads fresh Adds debug checks for file creation and permissions Exits script on error to avoid silent failures
1 parent a6cba45 commit 9579ae2

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

β€Žeditor/nginx.confβ€Ž

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ http {
3636
add_header Cache-Control "public";
3737
}
3838

39+
# Don't cache runtime configuration (needs to update with new environment variables)
40+
location = /runtime-config.js {
41+
expires -1;
42+
add_header Cache-Control "no-cache, no-store, must-revalidate";
43+
add_header Pragma "no-cache";
44+
}
45+
3946
# Don't cache the main HTML file
4047
location ~* \.html$ {
4148
expires -1;

β€Žeditor/startup.shβ€Ž

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e
23
# Azure App Service startup script
34
# This script creates a runtime configuration file from environment variables
45

@@ -16,31 +17,48 @@ echo "VITE_OAUTH_WEB_CLIENT_ID='${VITE_OAUTH_WEB_CLIENT_ID:-NOT SET}'"
1617
echo "VITE_OAUTH_WEB_CLIENT_SECRET='${VITE_OAUTH_WEB_CLIENT_SECRET:+SET}'"
1718
echo "VITE_NODE_ENV='${VITE_NODE_ENV:-NOT SET}'"
1819

20+
# DEBUG: Check if file exists before writing
21+
echo "πŸ” Checking if runtime-config.js exists before writing..."
22+
ls -la /usr/share/nginx/html/runtime-config.js 2>/dev/null || echo "File doesn't exist yet"
23+
24+
# Check directory permissions
25+
echo "πŸ” Directory permissions:"
26+
ls -la /usr/share/nginx/html/
27+
1928
# Create runtime configuration file
2029
echo "πŸ“„ Creating runtime configuration..."
30+
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
2131
cat > /usr/share/nginx/html/runtime-config.js << EOF
22-
// Runtime configuration for Azure App Service
32+
// Runtime configuration for Azure App Service - Generated: ${TIMESTAMP}
2333
window.runtimeConfig = {
2434
VITE_BACKEND_BASE_URL: '${VITE_BACKEND_BASE_URL}',
2535
VITE_LOGIN_BASE_URL: '${VITE_LOGIN_BASE_URL}',
2636
VITE_OAUTH_WEB_CLIENT_ID: '${VITE_OAUTH_WEB_CLIENT_ID}',
2737
VITE_OAUTH_WEB_CLIENT_SECRET: '${VITE_OAUTH_WEB_CLIENT_SECRET}',
28-
VITE_NODE_ENV: '${VITE_NODE_ENV}'
38+
VITE_NODE_ENV: '${VITE_NODE_ENV}',
39+
_generated: '${TIMESTAMP}'
2940
};
3041
3142
console.log('πŸ”§ Runtime configuration loaded for Azure App Service');
3243
console.log('πŸ“Š Config values:', window.runtimeConfig);
44+
console.log('πŸ• Generated at: ${TIMESTAMP}');
3345
EOF
3446

3547
echo "βœ… Runtime configuration created at /usr/share/nginx/html/runtime-config.js"
3648

37-
# Verify the file was created and show its content
38-
if [ -f "/usr/share/nginx/html/runtime-config.js" ]; then
39-
echo "πŸ“„ Runtime config file content:"
40-
head -15 /usr/share/nginx/html/runtime-config.js
41-
else
42-
echo "❌ Failed to create runtime config file!"
43-
fi
49+
# DEBUG: Verify what was actually written
50+
echo "πŸ“„ Runtime config file content after writing:"
51+
cat /usr/share/nginx/html/runtime-config.js
52+
53+
# DEBUG: Check file permissions after writing
54+
echo "οΏ½ File permissions after writing:"
55+
ls -la /usr/share/nginx/html/runtime-config.js
56+
57+
# DEBUG: Test file can be read by nginx user
58+
echo "πŸ” Testing nginx config:"
59+
nginx -t 2>/dev/null && echo "βœ… Nginx config valid" || echo "❌ Nginx config error"
60+
61+
echo "βœ… Runtime configuration setup complete!"
4462

4563
# Start nginx
4664
echo "🌐 Starting nginx..."

0 commit comments

Comments
Β (0)