Use baseUrl for auth-check api

Change-Id: I23d955e04c02b88705a515edde8186bb6772d862
This commit is contained in:
Tao Zhou
2020-01-12 15:57:02 +01:00
parent c4409bd739
commit 24e9a031de

View File

@@ -39,6 +39,10 @@
this._last_auth_check_time = Date.now();
}
get baseUrl() {
return Gerrit.BaseUrlBehavior.getBaseUrl();
}
/**
* Returns if user is authed or not.
*
@@ -49,7 +53,7 @@
(Date.now() - this._last_auth_check_time > MAX_AUTH_CHECK_WAIT_TIME_MS)
) {
// Refetch after last check expired
this._authCheckPromise = fetch('/auth-check');
this._authCheckPromise = fetch(`${this.baseUrl}/auth-check`);
this._last_auth_check_time = Date.now();
}
@@ -209,7 +213,7 @@
if (accessToken) {
params.push(`access_token=${accessToken}`);
const baseUrl = Gerrit.BaseUrlBehavior.getBaseUrl();
const baseUrl = this.baseUrl;
const pathname = baseUrl ?
url.substring(url.indexOf(baseUrl) + baseUrl.length) : url;
if (!pathname.startsWith('/a/')) {