Fix localhost

Handle automatic subdomain redirect
This commit is contained in:
Tom Moor
2018-11-03 22:40:33 -07:00
parent 6418712c47
commit 1be8e13828
6 changed files with 26 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
// @flow
import uuid from 'uuid';
import url from 'url';
import { URL } from 'url';
import { DataTypes, sequelize, Op } from '../sequelize';
import { publicS3Endpoint, uploadToS3FromUrl } from '../utils/s3';
import { RESERVED_SUBDOMAINS } from '../utils/domains';
@@ -47,11 +47,9 @@ const Team = sequelize.define(
url() {
if (!this.subdomain) return process.env.URL;
const u = url.parse(process.env.URL);
if (u.hostname) {
u.hostname = `${this.subdomain}.${u.hostname}`;
return u.href;
}
const url = new URL(process.env.URL);
url.host = `${this.subdomain}.${url.host}`;
return url.href.replace(/\/$/, '');
},
},
}