diff --git a/src/config/index.ts b/src/config/index.ts index 2060b62..f4a2eee 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -69,7 +69,7 @@ export function loadConfig( readOnlyEnv === "yes"; const portArg = parseCliArg(argv, "--port"); - const portStr = portArg ?? env.PORT; + const portStr = portArg ?? env.PORT ?? env.HOST_PORT; let port: number | undefined; if (portStr !== undefined && portStr.trim() !== "") { const parsed = parseInt(portStr.trim(), 10); diff --git a/tests/config.test.ts b/tests/config.test.ts index ec6b6d4..0b0dd75 100644 --- a/tests/config.test.ts +++ b/tests/config.test.ts @@ -82,6 +82,18 @@ describe("Configuration Loader (HTTP & Stdio Support)", () => { expect(config.apiKey).toBeUndefined(); }); + test("loads HTTP configuration when HOST_PORT is set as fallback without PORT", () => { + process.env.OPENPROJECT_BASE_URL = "https://openproject.example.com"; + delete process.env.OPENPROJECT_API_KEY; + delete process.env.PORT; + process.env.HOST_PORT = "3000"; + + const config = loadConfig(); + expect(config.baseUrl).toBe("https://openproject.example.com"); + expect(config.port).toBe(3000); + expect(config.apiKey).toBeUndefined(); + }); + test("loads HTTP configuration with API key when provided", () => { process.env.OPENPROJECT_BASE_URL = "https://openproject.example.com"; process.env.OPENPROJECT_API_KEY = "test-key";