From 8de074b275b6f893effaabf7bfcc1aeefe16145a Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 3 Nov 2018 23:24:44 -0700 Subject: [PATCH] Allow removing subdomain --- app/components/Auth.js | 5 +---- app/utils/ApiClient.js | 3 +++ server/api/team.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/components/Auth.js b/app/components/Auth.js index 19f111323..762a556a1 100644 --- a/app/components/Auth.js +++ b/app/components/Auth.js @@ -24,10 +24,7 @@ const Auth = observer(({ auth, children }: Props) => { return ; } - if ( - team.subdomain && - !window.location.hostname.startsWith(team.subdomain) - ) { + if (window.location.origin !== team.url) { window.location.href = `${team.url}${window.location.pathname}`; return ; } diff --git a/app/utils/ApiClient.js b/app/utils/ApiClient.js index de937a5df..b57724020 100644 --- a/app/utils/ApiClient.js +++ b/app/utils/ApiClient.js @@ -39,6 +39,8 @@ class ApiClient { const headers = new Headers({ Accept: 'application/json', 'Content-Type': 'application/json', + 'cache-control': 'no-cache', + pragma: 'no-cache', }); if (stores.auth.authenticated) { invariant(stores.auth.token, 'JWT token not set properly'); @@ -52,6 +54,7 @@ class ApiClient { headers, redirect: 'follow', credentials: 'omit', + cache: 'no-cache', }); if (response.status >= 200 && response.status < 300) { diff --git a/server/api/team.js b/server/api/team.js index 8b10d0abf..6e4bf5d79 100644 --- a/server/api/team.js +++ b/server/api/team.js @@ -19,8 +19,8 @@ router.post('team.update', auth(), async ctx => { const team = await Team.findById(user.teamId); authorize(user, 'update', team); + team.subdomain = subdomain === '' ? null : subdomain; if (name) team.name = name; - if (subdomain !== undefined) team.subdomain = subdomain; if (sharing !== undefined) team.sharing = sharing; if (avatarUrl && avatarUrl.startsWith(`${endpoint}/uploads/${user.id}`)) { team.avatarUrl = avatarUrl;