Compare commits

...

4 Commits

Author SHA1 Message Date
abeatrix bcf561c5b1 getCallbackUrl callback 2026-02-11 12:15:39 +09:00
abeatrix 6200f5e0c1 removes trailing slash 2026-02-11 10:20:41 +09:00
abeatrix 327808610c add changeset 2026-02-11 09:47:17 +09:00
abeatrix 8e9941cad9 fix: make AuthHandler.getCallbackUrl path parameter required
Change the `path` parameter of `getCallbackUrl()` from optional
(defaulting to empty string) to required, ensuring callers explicitly
specify the callback path. All call sites are updated to pass "/auth"
(or "/" in tests). Also upgrades the redirect URI error log from info
to error level for better diagnostics.

This fix issues where redirect url for auth is missing the auth path.
2026-02-11 09:45:33 +09:00
5 changed files with 15 additions and 12 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"cline": patch
---
Fix auth redirection issue for non VS Code clients.
+3 -3
View File
@@ -246,8 +246,8 @@ export class ClineAgent implements acp.Agent {
},
hostBridgeClientProvider,
(message: string) => Logger.info(message),
async () => {
return AuthHandler.getInstance().getCallbackUrl()
async (path: string) => {
return AuthHandler.getInstance().getCallbackUrl(path)
},
async () => "", // get binary location not needed in ACP mode
this.ctx.EXTENSION_DIR,
@@ -973,7 +973,7 @@ export class ClineAgent implements acp.Agent {
// Get the callback URL first to ensure the server is ready
let callbackUrl: string
try {
callbackUrl = await authHandler.getCallbackUrl()
callbackUrl = await authHandler.getCallbackUrl("/auth")
Logger.debug("[ClineAgent] Callback URL ready:", callbackUrl)
} catch (error) {
Logger.error("[ClineAgent] Failed to get callback URL:", error)
+2 -5
View File
@@ -73,10 +73,7 @@ async function disposeTelemetryServices(): Promise<void> {
}
telemetryDisposed = true
await Promise.allSettled([
telemetryService.dispose(),
PostHogClientProvider.getInstance().dispose(),
])
await Promise.allSettled([telemetryService.dispose(), PostHogClientProvider.getInstance().dispose()])
}
async function disposeCliContext(ctx: CliContext): Promise<void> {
@@ -433,7 +430,7 @@ async function initializeCli(options: InitOptions): Promise<CliContext> {
() => new StandaloneTerminalManager(),
createCliHostBridgeProvider(workspacePath),
logToChannel,
async () => (options.enableAuth ? AuthHandler.getInstance().getCallbackUrl() : ""),
async () => (options.enableAuth ? AuthHandler.getInstance().getCallbackUrl("/auth") : ""),
getCliBinaryPath,
EXTENSION_DIR,
DATA_DIR,
+4 -3
View File
@@ -40,7 +40,7 @@ export class AuthHandler {
this.enabled = enabled
}
public async getCallbackUrl(path = ""): Promise<string> {
public async getCallbackUrl(path: string): Promise<string> {
if (!this.enabled) {
throw Error("AuthHandler was not enabled")
}
@@ -58,7 +58,8 @@ export class AuthHandler {
this.updateTimeout()
}
return `http://127.0.0.1:${this.port}${path}`
// Use URL to ensure proper encoding of the path and removal of any trailing slash
return new URL(path, `http://127.0.0.1:${this.port}`).href.replace(/\/$/, "") // Remove trailing slash for consistency
}
private async createServer(): Promise<void> {
@@ -171,7 +172,7 @@ export class AuthHandler {
Logger.log("AuthHandler: Got redirect URI:", redirectUri)
} catch (error) {
// CLI or JetBrains mode - redirect not available
Logger.log("AuthHandler: No redirect URI available (CLI/JetBrains mode)")
Logger.error("AuthHandler: No redirect URI available (CLI/JetBrains mode)", error)
redirectUri = undefined
}
+1 -1
View File
@@ -47,7 +47,7 @@ describe("Auth Callback URL", () => {
authHandler = AuthHandler.getInstance()
authHandler.setEnabled(true)
const url = await authHandler.getCallbackUrl()
const url = await authHandler.getCallbackUrl("/")
url.should.startWith("http://127.0.0.1:")
url.should.match(/^http:\/\/127\.0\.0\.1:\d+$/)
})