Skip to content

Let the API listen on the port the docs already name - #23

Open
krongggggg wants to merge 1 commit into
CopilotKit:mainfrom
krongggggg:cursor/honor-server-port-f6a2
Open

Let the API listen on the port the docs already name#23
krongggggg wants to merge 1 commit into
CopilotKit:mainfrom
krongggggg:cursor/honor-server-port-f6a2

Conversation

@krongggggg

Copy link
Copy Markdown

What this changes

The documented way to move the API is SERVER_PORT. scripts/start.sh, the Vite /api proxy, and the ports table already use that name. The server process itself only read PORT, which is what .env.example used to set.

A clone that followed the docs and set SERVER_PORT could get Vite proxying to the new port while the API still listened on PORT=3001, and start.sh health-checking a port the process was not on.

The API now honours SERVER_PORT, then PORT, then 3001. Existing .env files that only set PORT keep working. Vite and start.sh follow the same order so the listener, the proxy, and the health check stay on the same number.

.env.example now names SERVER_PORT and APP_PORT instead of only PORT.

Where it runs

  • New state that outlives a request? None.
  • What happens on the second replica? Each process reads the same environment. The port it binds is the same on every process that shares that environment.
  • Anything serialised? None.
  • Anything fanned out to a browser? None.
  • New listener, port, or schedule? Same single HTTP listener as before. Only the environment variable that selects its port changed.

Boundary and audit

  • Every acting call still goes through the gateway: resolve, decide, audit, then act.
  • New refusals and new failures each write a row. None added.
  • Nothing new is trusted from the client that the server can resolve itself.

Proof

  • bun run format:check — clean
  • bun run lint — exit 0
  • bun run typecheck — app, server and worker all exit 0
  • bun test server/tests/listen-port.test.ts — 5 pass, 0 fail
  • bun run build — app, server and worker all exit 0

Test plan

  • Set SERVER_PORT (leave PORT at 3001 or unset) and confirm bun run dev listens and proxies on that port
  • Set only PORT and confirm the API still listens there
  • Set both to different values and confirm SERVER_PORT wins for the listener, the Vite proxy, and scripts/start.sh

SERVER_PORT is what start.sh, Vite, and the ports table already use; the
process only read PORT. Honour SERVER_PORT first, then PORT, so existing
.env files keep working and the documented name actually moves the listener.

Co-authored-by: krong <krongggggg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants