fix(install): always set app.allowedHostnames so the app starts in production

The shipped .env has no app.allowedHostnames line, so the previous sed was a
silent no-op. Since the installer sets CI_ENVIRONMENT=production, the app then
fails fast on first load (App.php throws when the whitelist is empty). Append
the key if it's missing, or substitute it if present.
This commit is contained in:
jekkos committed 2026-09-30 14:22:42 +00:00
1 parent 6b83e0f108
commit de21fdb682
1 file changed
+7 -1
+7 -1
View File
@@ -393,7 +393,13 @@ systemctl restart apache2
# Host-header validation accepts the domain the site is actually served at.
if [ -f "${OSPOS_DIR}/.env" ]; then
ALLOWED_HOST="${SSL_DOMAIN:-$APACHE_SERVER_NAME}"
sed -i "s|app\.allowedHostnames = ''|app.allowedHostnames = '${ALLOWED_HOST}'|" "${OSPOS_DIR}/.env"
# The shipped .env has no app.allowedHostnames line, so a plain sed is a silent
# no-op and production then 500s on first load; append it if it's missing.
if grep -Eq "^[[:space:]]*app\.allowedHostnames[[:space:]]*=" "${OSPOS_DIR}/.env"; then
sed -i "s|app\.allowedHostnames = .*|app.allowedHostnames = '${ALLOWED_HOST}'|" "${OSPOS_DIR}/.env"
else
printf "\napp.allowedHostnames = '%s'\n" "$ALLOWED_HOST" >> "${OSPOS_DIR}/.env"
fi
fi
echo ""