Fix: Proxy body serialization and optional chaining syntax
This commit is contained in:
@@ -320,6 +320,13 @@ app.use('/v1', requireAuth, createProxyMiddleware({
|
||||
// Add auth token for OpenClaw gateway
|
||||
proxyReq.setHeader('Authorization', `Bearer ${CONFIG.gatewayToken}`);
|
||||
proxyReq.setHeader('x-openclaw-agent-id', req.headers['x-openclaw-agent-id'] || 'main');
|
||||
|
||||
// Re-serialize body if it was already parsed by express.json()
|
||||
if (req.body && Object.keys(req.body).length > 0) {
|
||||
const bodyData = JSON.stringify(req.body);
|
||||
proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData));
|
||||
proxyReq.write(bodyData);
|
||||
}
|
||||
},
|
||||
onProxyRes: (proxyRes, req, res) => {
|
||||
// Handle SSE streaming
|
||||
|
||||
Reference in New Issue
Block a user