fix(view): respect APP_URL and X-Forwarded-* in getBaseUrl() — BIT-24927 #2

Merged
spark merged 1 commits from fix/bit-24925-crm-admin-pathmanager into master 2026-06-10 19:59:31 +01:00
Owner

Summary

Fixes asset URLs including :8080 suffix when app is behind NPM reverse proxy.

Root cause: View::getBaseUrl() appended SERVER_PORT=8080 (backend port) to the hostname.

Fix:

  • Check APP_URL env var first (explicit override for proxied deployments)
  • Fall back to X-Forwarded-Proto/X-Forwarded-Port headers before raw $_SERVER vars

Paired with APP_URL=https://crm-moneyflix.bitreport.pt in production .env on CT241.

Fixes BIT-24927

## Summary Fixes asset URLs including `:8080` suffix when app is behind NPM reverse proxy. **Root cause:** `View::getBaseUrl()` appended `SERVER_PORT=8080` (backend port) to the hostname. **Fix:** - Check `APP_URL` env var first (explicit override for proxied deployments) - Fall back to `X-Forwarded-Proto`/`X-Forwarded-Port` headers before raw `$_SERVER` vars Paired with `APP_URL=https://crm-moneyflix.bitreport.pt` in production `.env` on CT241. Fixes [BIT-24927](/BIT/issues/BIT-24927)
spark added 1 commit 2026-06-10 19:59:24 +01:00
When the app runs behind a reverse proxy (NPM), SERVER_PORT was 8080
(the backend port) causing asset URLs to include :8080 even though
clients access via HTTPS on port 443.

Priority: if APP_URL is set in the environment, use it directly.
Fallback: honour X-Forwarded-Proto and X-Forwarded-Port headers before
falling back to the raw SERVER vars.

Fixes crm-moneyflix.bitreport.pt asset URLs generating :8080 suffix.

Co-Authored-By: Paperclip <[email protected]>
spark merged commit 872ad2d1c6 into master 2026-06-10 19:59:31 +01:00
Sign in to join this conversation.