|
5 | 5 | *--------------------------------------------------------------------------
|
6 | 6 | */
|
7 | 7 |
|
8 | | - |
9 | 8 | import { Instance } from '@postgres.ai/shared/types/api/entities/instance'
|
10 | 9 |
|
11 | 10 | export const getCliInitCommand = (instance: Instance) =>
|
12 | 11 | `dblab init --url ${instance.url} --token TOKEN --environment-id ${instance.projectName}`
|
13 | 12 |
|
14 | 13 | export const getSshPortForwardingCommand = (instance: Instance) => {
|
15 | | - if (!instance.sshServerUrl) return null |
16 | | - return `ssh -NTML 2348:localhost:2345 ${instance.sshServerUrl} -i ~/.ssh/id_rsa` |
| 14 | + if (instance.sshServerUrl) { |
| 15 | + // Parse the URL to get the port |
| 16 | + const url = new URL(instance.url) |
| 17 | + const port = url.port || '2345' |
| 18 | + return `ssh -NTML ${port}:localhost:${port} ${instance.sshServerUrl} -i ~/.ssh/id_rsa` |
| 19 | + } else { |
| 20 | + return null |
| 21 | + } |
17 | 22 | }
|
0 commit comments