jaysylvester / citizen

Node.js MVC web application framework. Includes routing, serving, caching, session management, and other helpful tools.
MIT License
100 stars 7 forks source link

The router should reflect the public host and protocol #99

Closed jaysylvester closed 3 years ago

jaysylvester commented 3 years ago

Behind a proxy, the router uses the host (request.headers.host) when constructing route.url, but not the host protocol:

Web address: https://website.com/page App server: http://127.0.0.1:8080/page route.url: http://website.com/page

The router should check for the existence of X-Forwarded-Host and X-Forwarded-Scheme and construct route.url using the public host and protocol (https://website.com/page).

Consider adding a new route property to store the app server URL (including the port), such as route.proxiedURL so server logs can reference the correct value (public app server logs would contain the original web address, while app servers behind proxies would reflect the app server URL in their logs).