Skip to content

Commit e0d1d45

Browse files
dcramerclaude
andcommitted
fix: use localhost instead of 127.0.0.1 for OAuth callback
This fixes the OAuth flow in WSL2 where 127.0.0.1 inside WSL is not accessible from the Windows host browser. Using localhost enables WSL2's built-in localhost forwarding between Windows and WSL. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 0b286f1 commit e0d1d45

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/opencode/src/mcp/oauth-callback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export namespace McpOAuthCallback {
161161
export async function isPortInUse(): Promise<boolean> {
162162
return new Promise((resolve) => {
163163
Bun.connect({
164-
hostname: "127.0.0.1",
164+
hostname: "localhost",
165165
port: OAUTH_CALLBACK_PORT,
166166
socket: {
167167
open(socket) {

packages/opencode/src/mcp/oauth-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class McpOAuthProvider implements OAuthClientProvider {
3232
) {}
3333

3434
get redirectUrl(): string {
35-
return `http://127.0.0.1:${OAUTH_CALLBACK_PORT}${OAUTH_CALLBACK_PATH}`
35+
return `http://localhost:${OAUTH_CALLBACK_PORT}${OAUTH_CALLBACK_PATH}`
3636
}
3737

3838
get clientMetadata(): OAuthClientMetadata {

0 commit comments

Comments
 (0)