(core) fix redirects for multi-team Grist on a single domain

Summary:
The logic for calculating redirects wasn't quite right for Grist
configured to use a single domain, with teams encoded in the path.
This fixes it.

Test Plan: tested manually with docker compose and /etc/hosts

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3359
This commit is contained in:
Paul Fitzpatrick
2022-04-05 11:48:15 -04:00
parent bb5f3fc378
commit 6c6bfee00e
2 changed files with 8 additions and 6 deletions

View File

@@ -1515,12 +1515,8 @@ export class FlexServer implements GristServer {
* path.
*/
private _getOrgRedirectUrl(req: RequestWithLogin, subdomain: string, pathname: string = req.originalUrl): string {
const {hostname, orgInPath} = getOrgUrlInfo(subdomain, req.get('host')!, {
org: req.org,
baseDomain: this._defaultBaseDomain,
pluginUrl: this._pluginUrl,
singleOrg: process.env.GRIST_SINGLE_ORG,
});
const config = this.getGristConfig();
const {hostname, orgInPath} = getOrgUrlInfo(subdomain, req.get('host')!, config);
const redirectUrl = new URL(pathname, `${req.protocol}://${req.get('host')}`);
if (hostname) {
redirectUrl.hostname = hostname;