Skip to content

Commit 1d591bb

Browse files
committed
address comments
1 parent 1b43bd5 commit 1d591bb

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/sdk/devbox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ export class Devbox {
845845
throw new RunloopError('No tunnel has been enabled for this devbox. Call net.enableTunnel() first.');
846846
}
847847
const apiHost = new URL(this.client.baseURL).hostname;
848-
const baseDomain = apiHost.split('.').slice(-2).join('.');
848+
const baseDomain = apiHost.startsWith('api.') ? apiHost.slice(4) : apiHost;
849849
return `https://${port}-${tunnel.tunnel_key}.tunnel.${baseDomain}`;
850850
}
851851

tests/objects/devbox.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ describe('Devbox (New API)', () => {
305305
});
306306

307307
it('should derive tunnel domain from client baseURL', async () => {
308-
mockClient.baseURL = 'https://api.runloop.pro';
309308
const mockTunnel = {
310309
tunnel_key: 'abc123xyz',
311310
auth_mode: 'open' as const,
@@ -314,9 +313,11 @@ describe('Devbox (New API)', () => {
314313
const dataWithTunnel = { ...mockDevboxData, tunnel: mockTunnel };
315314
mockClient.devboxes.retrieve.mockResolvedValue(dataWithTunnel);
316315

317-
const url = await devbox.getTunnelUrl(8080);
316+
mockClient.baseURL = 'https://api.runloop.pro';
317+
expect(await devbox.getTunnelUrl(8080)).toBe('https://8080-abc123xyz.tunnel.runloop.pro');
318318

319-
expect(url).toBe('https://8080-abc123xyz.tunnel.runloop.pro');
319+
mockClient.baseURL = 'http://127.0.0.1:8080';
320+
expect(await devbox.getTunnelUrl(8080)).toBe('https://8080-abc123xyz.tunnel.127.0.0.1');
320321

321322
mockClient.baseURL = 'https://api.runloop.ai';
322323
});

0 commit comments

Comments
 (0)