Skip to content

Commit 4bf5113

Browse files
fix(web): preserve context path in OAuth token refresh URL construction
Using absolute paths (e.g. '/rest/...') with new URL() drops any pathname from the base URL. Normalize the base to end with '/' and use relative paths so deployments with a context path (e.g. https://example.com/bitbucket) resolve correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2e30395 commit 4bf5113

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/web/src/ee/features/permissionSyncing/tokenRefresh.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,15 @@ const tryRefreshToken = async (
218218

219219
let url: string;
220220
if (baseUrl) {
221+
// Use a trailing-slash-normalized base so relative paths append correctly,
222+
// preserving any context path (e.g. https://example.com/bitbucket/).
223+
const base = baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';
221224
if (provider === 'github') {
222-
url = new URL('/login/oauth/access_token', baseUrl).toString();
225+
url = new URL('login/oauth/access_token', base).toString();
223226
} else if (provider === 'bitbucket-server') {
224-
url = new URL('/rest/oauth2/latest/token', baseUrl).toString();
227+
url = new URL('rest/oauth2/latest/token', base).toString();
225228
} else {
226-
url = new URL('/oauth/token', baseUrl).toString();
229+
url = new URL('oauth/token', base).toString();
227230
}
228231
} else if (provider === 'github') {
229232
url = 'https://github.com/login/oauth/access_token';

0 commit comments

Comments
 (0)