diff --git a/server/app/api/proxy/[[...path]]/route.ts b/server/app/api/proxy/[[...path]]/route.ts index 1008cc5..7150582 100644 --- a/server/app/api/proxy/[[...path]]/route.ts +++ b/server/app/api/proxy/[[...path]]/route.ts @@ -111,7 +111,8 @@ async function proxyRequest(req: NextRequest) { }); } - // For text responses, rewrite localhost/internal URLs to the public URL + // For text responses, rewrite localhost/internal URLs to the public URL. + // Also handle protocol-relative URLs that some WordPress plugins/themes use. let body = await upstreamRes.text(); const localBase = `http://${instance.node.tailscaleIp}:${instance.port}`; const localBaseHttps = `https://${instance.node.tailscaleIp}:${instance.port}`; @@ -119,6 +120,8 @@ async function proxyRequest(req: NextRequest) { const localLocalhostHttps = `https://localhost:${instance.port}`; const localLocalhostPlainHttp = `http://localhost`; const localLocalhostPlainHttps = `https://localhost`; + const localLocalhostProtocolRelative = `//localhost`; + const localTailscaleProtocolRelative = `//${instance.node.tailscaleIp}:${instance.port}`; body = body .replaceAll(localBase, publicUrl) @@ -126,7 +129,9 @@ async function proxyRequest(req: NextRequest) { .replaceAll(localLocalhostHttp, publicUrl) .replaceAll(localLocalhostHttps, publicUrl) .replaceAll(localLocalhostPlainHttp, publicUrl) - .replaceAll(localLocalhostPlainHttps, publicUrl); + .replaceAll(localLocalhostPlainHttps, publicUrl) + .replaceAll(localTailscaleProtocolRelative, publicUrl.replace(/^https?:/, "")) + .replaceAll(localLocalhostProtocolRelative, publicUrl.replace(/^https?:/, "")); return new Response(body, { status: upstreamRes.status, diff --git a/server/app/api/websocket/route.ts b/server/app/api/websocket/route.ts index c763e43..6ee9fbc 100644 --- a/server/app/api/websocket/route.ts +++ b/server/app/api/websocket/route.ts @@ -5,8 +5,14 @@ const globalWss = globalThis as typeof globalThis & { __eduboxWss?: WebSocketSer if (!globalWss.__eduboxWss) { try { - globalWss.__eduboxWss = new WebSocketServer({ port: 3001 }); - initWebSocketServer(globalWss.__eduboxWss); + const wss = new WebSocketServer({ port: 3001 }); + wss.on("error", (err) => { + // Silently ignore EADDRINUSE during build/hot reload; the existing + // server will keep handling agent connections. + console.warn("WebSocket server error:", (err as Error).message); + }); + globalWss.__eduboxWss = wss; + initWebSocketServer(wss); } catch { // Port may be in use during build or hot reload }