fix(server): accept SERVER_PORT alias and fail fast on PORT/SERVER_PORT mismatch - #312
Merged
davidmckayv merged 1 commit intoSep 1, 2026
Conversation
…RT mismatch The server only read PORT while scripts/start.sh and app/vite.config.ts honour SERVER_PORT/APP_PORT. An operator who followed docs and set SERVER_PORT=4000 ended up with a server on 3001 and a proxy on 4000 that accepted whatever else was on 3001 (HTML as JSON). Now the server prefers PORT but falls back to SERVER_PORT and refuses to start when both are set to different values, so a single edit works and a split edit fails where somebody is looking. .env.example comment updated to match the new behaviour.
Ayush7614
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso and
tylerslaton
as code owners
September 1, 2026 08:47
davidmckayv
approved these changes
Sep 1, 2026
davidmckayv
left a comment
Contributor
There was a problem hiding this comment.
Correct, and the hard failure is the right one: the trap the .env.example comment already described at length was a silent misconfiguration, and this makes it loud. Checked the deploy paths, nothing sets PORT and SERVER_PORT to different values (the PORT: "4300" in docker-compose.yml is the supervisor, a different process). CI green.
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The server only read
PORT(server/src/index.ts:146):ts const port = Number.parseInt(process.env.PORT ?? "3001", 10);while
scripts/start.shandapp/vite.config.tshonourSERVER_PORT/APP_PORT, anddocs/configuration.md+.env.exampledocumentSERVER_PORTas the setting. An operator who followed the docs and setSERVER_PORT=4000(or edited onlyPORT) ended up with:start.shhealth-check on 4000200from whatever else was on 3001 accepted as proof, then HTML parsed as JSON several stages laterDockerfile/composemasked it because they setPORTdirectly.Fix
server/src/index.ts:145-155: readPORT ?? SERVER_PORT ?? "3001", preferringPORTbut falling back toSERVER_PORT. If both are set and disagree, throw at boot where somebody is looking instead of failing late as a JSON parse error..env.example:10-20: comment updated to describe the alias behaviour and that a single edit now suffices (both equal remains valid).Behaviour verified:
Verification
bun run lint— pass (0 warnings)bun run format:check— passManual port-logic checks above — pass
No schema, migration, or dependency changes.