Skip to content

fix(prod): respect LOCAL_PORT + anchor public write paths to __dirname - #115

Merged
datvt243 merged 1 commit into
stagingfrom
fix/prod-port-ignores-local-port
Sep 8, 2026
Merged

fix(prod): respect LOCAL_PORT + anchor public write paths to __dirname#115
datvt243 merged 1 commit into
stagingfrom
fix/prod-port-ignores-local-port

Conversation

@datvt243

@datvt243 datvt243 commented Sep 8, 2026

Copy link
Copy Markdown
Owner

e003ec3 fix(prod): respect LOCAL_PORT + anchor public write paths to __dirname

Fixes 2 real bugs found live while building Docker support (#24), both surfaced by testing a minimal production image with no src/ tree — but both affect the real Render production deploy too, not just Docker.

  1. src/server.ts — production always hardcoded port 3008, silently ignoring LOCAL_PORT. Now respects it when set, still defaults to 3001 dev / 3008 prod when unset.
  2. createPDF.ts / uploadCV.middleware.ts / uploadImages.middleware.ts — all 3 wrote to a bare relative src/public/... path that never matched what express.static actually serves in a compiled run. PDF export hard-crashed; CV/image uploads silently 404'd forever on their own returned URL. Now all 3 resolve off __dirname.

Nodes: fix-prod-port-ignores-local-port (SEALED), fix-hardcoded-src-public-write-paths (SEALED) — both live-verified end-to-end in Docker (see evidence notes in the commit).

Fixes 2 real bugs found live while building Docker support
(add-docker-support, #24), both surfaced by testing a minimal production
image that has no src/ tree — but both affect the real Render production
deploy too, not just Docker.

1. src/server.ts:135 (fix-prod-port-ignores-local-port) — production
   always hardcoded port 3008, silently ignoring LOCAL_PORT. Now respects
   LOCAL_PORT whenever it's actually set, in any environment; still
   defaults to 3001 dev / 3008 prod when unset, so a deploy that's never
   set LOCAL_PORT keeps its current port unchanged.

2. src/services/createPDF.ts, uploadCV.middleware.ts,
   uploadImages.middleware.ts (fix-hardcoded-src-public-write-paths) —
   all 3 wrote to a bare relative `src/public/...` literal (CWD-relative,
   not __dirname-relative), which never matches what
   express.static(path.join(__dirname, 'public')) actually serves in a
   compiled run (dist/public/...). PDF export hard-crashed (ENOENT,
   Puppeteer doesn't auto-create dirs); CV/image uploads silently
   "succeeded" into a directory nothing serves, 404ing forever on their
   own returned URL. Now all 3 resolve off __dirname, matching
   express.static exactly in both dev and compiled runs.

docker-compose.prod.yml and Dockerfile's HEALTHCHECK reverted from the
add-docker-support round-2 hardcoded-3008 workaround back to
LOCAL_PORT-templating (now safe); Dockerfile's mkdir -p src/public/...
workaround removed (no longer needed — all 3 paths now self-create
under the correct dist/public/... location).

- npm run build: clean (tsc && npm run copy)
- npm test: 13 suites / 77 tests passed (unchanged — no Jest coverage
  for these paths; acceptance verified via live Docker container
  testing instead, see evidence)
- Live-verified in Docker production target: LOCAL_PORT unset still
  defaults to 3008 (no regression); LOCAL_PORT set to a non-default
  value is genuinely respected and reaches healthy; PDF export,
  image upload+fetch, and CV upload+download all confirmed working
  end-to-end with byte-identical file round trips, with src/ confirmed
  absent from the image (rules out "worked by accident")

Nodes: fix-prod-port-ignores-local-port (SEALED),
fix-hardcoded-src-public-write-paths (SEALED)
Evidence: agent-hub/evidence/implementer/2026-09-06/fix-prod-port-ignores-local-port-diff.md,
agent-hub/evidence/verifier/2026-09-06/fix-prod-port-ignores-local-port-seal.md,
agent-hub/evidence/implementer/2026-09-06/fix-hardcoded-src-public-write-paths-diff.md,
agent-hub/evidence/verifier/2026-09-06/fix-hardcoded-src-public-write-paths-seal.md

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@datvt243
datvt243 merged commit 5564e25 into staging Sep 8, 2026
3 checks passed
@datvt243
datvt243 deleted the fix/prod-port-ignores-local-port branch September 8, 2026 15:42
@datvt243 datvt243 mentioned this pull request Sep 8, 2026
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.

1 participant