()
| 49 | * Get the server port to use |
| 50 | */ |
| 51 | export function getServerPort(): number { |
| 52 | // Explicit port from environment takes precedence |
| 53 | const envPort = process.env.PLANNOTATOR_PORT; |
| 54 | if (envPort) { |
| 55 | const parsed = parseInt(envPort, 10); |
| 56 | if (!isNaN(parsed) && parsed >= 0 && parsed < 65536) { |
| 57 | return parsed; |
| 58 | } |
| 59 | console.error( |
| 60 | `[Plannotator] Warning: Invalid PLANNOTATOR_PORT "${envPort}", using default` |
| 61 | ); |
| 62 | } |
| 63 | |
| 64 | // Remote sessions use fixed port for port forwarding; local uses random |
| 65 | return isRemoteSession() ? DEFAULT_REMOTE_PORT : 0; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Bind local sessions to loopback, but keep remote sessions reachable via the |
no test coverage detected