@lifeaitools/clauth 1.5.33 → 1.5.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/serve.js +10 -2
- package/package.json +1 -1
package/cli/commands/serve.js
CHANGED
|
@@ -2997,11 +2997,19 @@ function createServer(initPassword, whitelist, port, tunnelHostnameInit = null,
|
|
|
2997
2997
|
const acceptsSSE = (req.headers.accept || "").includes("text/event-stream");
|
|
2998
2998
|
|
|
2999
2999
|
// Helper: respond in SSE or JSON format based on client preference
|
|
3000
|
+
// SSE response matches regen-media/Express exactly: no CORS, Content-Length, x-powered-by
|
|
3000
3001
|
function mcpRespond(res, jsonRpcResponse) {
|
|
3001
3002
|
if (acceptsSSE) {
|
|
3002
3003
|
const ssePayload = `event: message\ndata: ${JSON.stringify(jsonRpcResponse)}\n\n`;
|
|
3003
|
-
|
|
3004
|
-
|
|
3004
|
+
const buf = Buffer.from(ssePayload, "utf8");
|
|
3005
|
+
res.writeHead(200, {
|
|
3006
|
+
"Content-Type": "text/event-stream",
|
|
3007
|
+
"Content-Length": buf.length,
|
|
3008
|
+
"Cache-Control": "no-cache",
|
|
3009
|
+
"vary": "Accept-Encoding",
|
|
3010
|
+
"x-powered-by": "Express",
|
|
3011
|
+
});
|
|
3012
|
+
return res.end(buf);
|
|
3005
3013
|
}
|
|
3006
3014
|
res.writeHead(200, { "Content-Type": "application/json", ...CORS });
|
|
3007
3015
|
return res.end(JSON.stringify(jsonRpcResponse));
|