fix(mcp): bind oauth callback to IPv4 loopback (#30022)

This commit is contained in:
Yufeng He
2026-06-24 12:20:29 +08:00
committed by GitHub
parent 5303ab09f8
commit af31e97493
2 changed files with 45 additions and 1 deletions
+3 -1
View File
@@ -3,6 +3,8 @@ import { createServer } from "http"
import { escapeHtml } from "@/util/html"
import { OAUTH_CALLBACK_PORT, OAUTH_CALLBACK_PATH, parseRedirectUri } from "./oauth-provider"
const OAUTH_CALLBACK_HOST = "127.0.0.1"
// Current callback server configuration (may differ from defaults if custom redirectUri is used)
let currentPort = OAUTH_CALLBACK_PORT
let currentPath = OAUTH_CALLBACK_PATH
@@ -162,7 +164,7 @@ export async function ensureRunning(redirectUri?: string): Promise<void> {
server = createServer(handleRequest)
await new Promise<void>((resolve, reject) => {
server!.listen(currentPort, () => {
server!.listen(currentPort, OAUTH_CALLBACK_HOST, () => {
resolve()
})
server!.on("error", reject)