fix: terminal command execution via HTTP POST workaround
The WebSocket send mechanism fails with close code 1006 when client tries to send data to server. Server never receives the message, indicating a network/proxy layer issue that couldn't be fixed through code changes or nginx configuration. Solution: Bypass WebSocket send entirely by using HTTP POST to send commands directly to the PTY. Changes: - Added sendTerminalInput() method to terminal-service.js that writes directly to PTY, bypassing WebSocket - Added POST endpoint /claude/api/terminals/:id/input to server.js - Modified launchCommand() in terminal.js to use fetch() with HTTP POST instead of WebSocket.send() The WebSocket receive direction still works (server→client for output display), only send direction (client→server for commands) is bypassed. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
23
server.js
23
server.js
@@ -1506,6 +1506,29 @@ app.delete('/claude/api/terminals/:id', requireAuth, (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Send input to terminal via HTTP (WebSocket workaround)
|
||||
app.post('/claude/api/terminals/:id/input', requireAuth, (req, res) => {
|
||||
try {
|
||||
const { data } = req.body;
|
||||
|
||||
if (!data) {
|
||||
res.status(400).json({ error: 'Missing data parameter' });
|
||||
return;
|
||||
}
|
||||
|
||||
const result = terminalService.sendTerminalInput(req.params.id, data);
|
||||
|
||||
if (result.success) {
|
||||
res.json({ success: true });
|
||||
} else {
|
||||
res.status(404).json({ error: result.error });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error sending terminal input:', error);
|
||||
res.status(500).json({ error: 'Failed to send input' });
|
||||
}
|
||||
});
|
||||
|
||||
// Get recent directories for terminal picker
|
||||
app.get('/claude/api/files/recent-dirs', requireAuth, (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user