Skip to content

Commit 5af7c81

Browse files
committed
address comments
1 parent 95e9a3a commit 5af7c81

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
@@ -839,7 +839,7 @@ export class Devbox {
839839
throw new RunloopError('No tunnel has been enabled for this devbox. Call net.enableTunnel() first.');
840840
}
841841
const apiHost = new URL(this.client.baseURL).hostname;
842-
const baseDomain = apiHost.split('.').slice(-2).join('.');
842+
const baseDomain = apiHost.startsWith('api.') ? apiHost.slice(4) : apiHost;
843843
return `https://${port}-${tunnel.tunnel_key}.tunnel.${baseDomain}`;
844844
}
845845

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)