Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirect tracing #486

Draft
wants to merge 1 commit into
base: v2.x/staging
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/webapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -1560,16 +1560,19 @@ WebApp.prototype = {
if ((req.get('x-forwarded-port') != gatewayPort)
&& (req.get('x-forwarded-host') != `${gatewayHost}:${gatewayPort}`)
&& ( req.query['zwed-no-redirect'] != 1 )) {
console.log(`default: redirecting user to ${this.options.gatewayRedirect+'/'} due to headers port=${req.get('x-forwarded-port')} and host=${req.get('x-forwarded-host')} without query`);
res.redirect(this.options.gatewayRedirect+'/');
} else if (this.options.componentConfig.node.rootRedirectURL) {
//will go to either gateway full url or own full url depending upon zwed-no-redirect.
console.log(`miss: redirecting user to .${this.options.componentConfig.node.rootRedirectURL} due to header port=${req.get('x-forwarded-port')} and host=${req.get('x-forwarded-host')} or query`);
res.redirect(
url.format({
pathname:'.'+this.options.componentConfig.node.rootRedirectURL,
query: req.query
})
);
} else {
console.log(`else case, next`);
next();
}
});
Expand All @@ -1579,14 +1582,17 @@ WebApp.prototype = {
if ((req.get('x-forwarded-port') != gatewayPort)
&& (req.get('x-forwarded-host') != `${gatewayHost}:${gatewayPort}`)
&& ( req.query['zwed-no-redirect'] != 1 )) {
console.log(`default2: redirecting user to ${this.options.gatewayRedirect+this.options.componentConfig.node.rootRedirectURL} due to headers port=${req.get('x-forwarded-port')} and host=${req.get('x-forwarded-host')} without query`);
res.redirect(this.options.gatewayRedirect+this.options.componentConfig.node.rootRedirectURL);
} else {
console.log(`else case2, next`);
next();
}
});
}
} else if (this.options.componentConfig.node.rootRedirectURL) {
this.expressApp.get('/', (req,res) => {
console.log(`no apiml, basic redirect to .${this.options.componentConfig.node.rootRedirectURL}`);
res.redirect('.'+this.options.componentConfig.node.rootRedirectURL);
});
this.expressApp.use('.'+this.options.componentConfig.node.rootRedirectURL, express.static(webdir));
Expand Down