···66# Process KANEO_API_URL first (with special handling)
77if [ ! -z "$KANEO_API_URL" ]; then
88 echo "Found KANEO_API_URL: $KANEO_API_URL"
99-99+1010 # First, replace the exact string "KANEO_API_URL" in all JavaScript files
1111 # Use grep -l to only process files that contain the string
1212 find /usr/share/nginx/html -type f -name "*.js" -exec grep -l "KANEO_API_URL" {} \; | xargs -r sed -i "s#KANEO_API_URL#$KANEO_API_URL#g"
1313-1313+1414 # Also check for the escaped version which might appear in some files
1515 find /usr/share/nginx/html -type f -name "*.js" -exec grep -l "\"KANEO_API_URL\"" {} \; | xargs -r sed -i "s#\"KANEO_API_URL\"#\"$KANEO_API_URL\"#g"
1616-1616+1717+ # Replace placeholder in nginx config so /.well-known proxies to the API
1818+ sed -i "s#KANEO_API_URL_PLACEHOLDER#$KANEO_API_URL#g" /etc/nginx/conf.d/default.conf
1919+1720 echo "✅ Replaced KANEO_API_URL with $KANEO_API_URL"
1821else
1922 echo "WARNING: KANEO_API_URL environment variable is not set. API calls may fail."
2323+ # Remove the proxy block so nginx doesn't fail on missing upstream
2424+ sed -i '/KANEO_API_URL_PLACEHOLDER/,+3d' /etc/nginx/conf.d/default.conf
2025fi
21262227# Process KANEO_CLIENT_URL efficiently