Skip to content

Commit fdeae9f

Browse files
committed
Fix: Docker connection issue in sandbox by binding to all interfaces
The application port in the sandbox environment (Docker) couldn't be accessed by the IDE when listening on the loopback address (127.0.0.1). This patch updates the binding address from '127.0.0.1' to '0.0.0.0' to listen on all available network interfaces, ensuring connectivity with external processes like the IDE. Damian
1 parent e8a065c commit fdeae9f

1 file changed

Lines changed: 2 additions & 14 deletions

File tree

packages/vscode-ide-companion/src/ide-server.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,6 @@ export class IDEServer {
159159
}),
160160
);
161161

162-
app.use((req, res, next) => {
163-
const host = req.headers.host || '';
164-
const allowedHosts = [
165-
`localhost:${this.port}`,
166-
`127.0.0.1:${this.port}`,
167-
];
168-
if (!allowedHosts.includes(host)) {
169-
return res.status(403).json({ error: 'Invalid Host header' });
170-
}
171-
next();
172-
});
173-
174162
app.use((req, res, next) => {
175163
const authHeader = req.headers.authorization;
176164
if (authHeader) {
@@ -322,7 +310,7 @@ export class IDEServer {
322310
}
323311
});
324312

325-
this.server = app.listen(0, '127.0.0.1', async () => {
313+
this.server = app.listen(0, '0.0.0.0', async () => {
326314
const address = (this.server as HTTPServer).address();
327315
if (address && typeof address !== 'string') {
328316
this.port = address.port;
@@ -334,7 +322,7 @@ export class IDEServer {
334322
os.tmpdir(),
335323
`gemini-ide-server-${process.ppid}.json`,
336324
);
337-
this.log(`IDE server listening on http://127.0.0.1:${this.port}`);
325+
this.log(`IDE server listening on http://0.0.0.0:${this.port}`);
338326

339327
if (this.authToken) {
340328
await writePortAndWorkspace({

0 commit comments

Comments
 (0)