diff --git a/apps/t3/src/runtimeApiServer.test.ts b/apps/t3/src/runtimeApiServer.test.ts index 511d19ff82..253d6fa167 100644 --- a/apps/t3/src/runtimeApiServer.test.ts +++ b/apps/t3/src/runtimeApiServer.test.ts @@ -317,6 +317,16 @@ describe("runtimeApiServer", () => { ).rejects.toThrow("Invalid runtime auth token"); }); + it("rejects non-string auth token configuration", async () => { + await expect( + startRuntimeApiServer({ + port: 0, + launchCwd: process.cwd(), + authToken: 123 as unknown as string, + }), + ).rejects.toThrow("Invalid runtime auth token"); + }); + it("accepts websocket connections without token when auth is disabled", async () => { const server = await startRuntimeApiServer({ port: 0, diff --git a/apps/t3/src/runtimeApiServer.ts b/apps/t3/src/runtimeApiServer.ts index fe08486489..3f2629fba4 100644 --- a/apps/t3/src/runtimeApiServer.ts +++ b/apps/t3/src/runtimeApiServer.ts @@ -344,6 +344,9 @@ export async function startRuntimeApiServer( throw new Error("Invalid runtime port: expected integer between 0 and 65535."); } const launchCwd = resolveExistingDirectory(options.launchCwd, "Invalid launchCwd"); + if (options.authToken !== undefined && typeof options.authToken !== "string") { + throw new Error("Invalid runtime auth token: expected non-empty string."); + } const authToken = options.authToken?.trim(); if (options.authToken !== undefined && !authToken) { throw new Error("Invalid runtime auth token: expected non-empty string.");