Skip to content

Commit 074e2d6

Browse files
author
Nik Samokhvalov
committed
fix(cli): pass api_url to UI for OAuth to ensure same backend is used
When user has a custom apiBaseUrl in config (e.g., staging v2.postgres.ai), the CLI now passes this URL to the UI via api_url query param. This ensures oauth_approve is called on the same backend where oauth_init created the session, preventing 'OAuth session not found' errors due to API/UI backend mismatch.
1 parent eb557fb commit 074e2d6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cli/bin/postgres-ai.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,8 @@ auth
21022102
}
21032103

21042104
// Step 3: Open browser
2105-
const authUrl = `${uiBaseUrl}/cli/auth?state=${encodeURIComponent(params.state)}&code_challenge=${encodeURIComponent(params.codeChallenge)}&code_challenge_method=S256&redirect_uri=${encodeURIComponent(redirectUri)}`;
2105+
// Pass api_url so UI calls oauth_approve on the same backend where oauth_init created the session
2106+
const authUrl = `${uiBaseUrl}/cli/auth?state=${encodeURIComponent(params.state)}&code_challenge=${encodeURIComponent(params.codeChallenge)}&code_challenge_method=S256&redirect_uri=${encodeURIComponent(redirectUri)}&api_url=${encodeURIComponent(apiBaseUrl)}`;
21062107

21072108
if (opts.debug) {
21082109
console.log(`Debug: Auth URL: ${authUrl}`);

0 commit comments

Comments
 (0)