zowe / zlux

The top-level superproject for zLUX. zLUX includes the Zowe Desktop framework in addition to several built-in apps and an example server implementation.
Eclipse Public License 2.0
39 stars 42 forks source link

Redirect to the gateway when it exists #918

Closed 1000TurquoisePogs closed 6 months ago

1000TurquoisePogs commented 1 year ago

In v2, issues like #863 appear when you access the desktop directly rather than through the gateway. When the gateway is up, you want to use it because it helps with HA, load balancing, port management, security, etc etc. People shouldn't be accessing the desktop directly if they can help it.

So, if a request comes into the desktop that doesnt originate from the gateway, we should redirect to it! The code should probably go right here https://github.com/zowe/zlux-server-framework/blob/v2.x/staging/lib/webapp.js#L1570-L1581 where we already do res.redirect but not to the gateway.

The main challenge is we CANT redirect if the request came from the gateway. This would cause an infinite loop of redirects. So, we need a way... something from the req object to know the request is/isnt from the gateway, and CONDITIONALLY redirect based upon that.

1000TurquoisePogs commented 1 year ago

i found the gateway has headers,

x-forwarded-host: zowe_host:port x-forwarded-prefix: /zlux/ui/v1 x-forwarded-port: 7554

this seems to be the info necessary to determine whether or not to redirect.

1000TurquoisePogs commented 6 months ago

This was implemented in 2.10.0