fix: 使用127.0.0.1替代localhost以确保IPv4连接,避免IPv6解析问题

This commit is contained in:
catlog22
2026-03-06 11:43:14 +08:00
parent 33cc451b61
commit 88149b6154
3 changed files with 5 additions and 4 deletions

View File

@@ -771,7 +771,7 @@ export async function startServer(options: ServerOptions = {}): Promise<http.Ser
}
// Otherwise, proxy to Vite dev server
const reactUrl = `http://localhost:${reactPort}${pathname}${url.search}`;
const reactUrl = `http://127.0.0.1:${reactPort}${pathname}${url.search}`;
try {
// Convert headers to plain object for fetch
@@ -783,7 +783,7 @@ export async function startServer(options: ServerOptions = {}): Promise<http.Ser
proxyHeaders[key] = value.join(', ');
}
}
proxyHeaders['host'] = `localhost:${reactPort}`;
proxyHeaders['host'] = `127.0.0.1:${reactPort}`;
const reactResponse = await fetch(reactUrl, {
method: req.method,