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]>