feat: production static serving + configurable port/state#9
Open
chrismdp wants to merge 2 commits intoJamsusMaximus:mainfrom
Open
feat: production static serving + configurable port/state#9chrismdp wants to merge 2 commits intoJamsusMaximus:mainfrom
chrismdp wants to merge 2 commits intoJamsusMaximus:mainfrom
Conversation
- Serve client/dist/ via express.static() so one process handles everything in production (no separate Vite dev server needed) - Add catch-all route for React Router paths (/, /hotel) - Make PORT configurable via env var (default 5174) - Make state file path configurable via CODEMAP_STATE_FILE env var to avoid writing into the watched project directory Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The server uses "type": "module" so __dirname is unavailable. Use fileURLToPath(import.meta.url) to resolve the client dist directory path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
client/dist/viaexpress.static()so one process handles everything in production/,/hotel)PORTconfigurable via env var (default 5174)CODEMAP_STATE_FILEenv varRationale
For production deployment behind a reverse proxy, the Express server should serve the built client directly rather than requiring a separate Vite dev server. The state file path needs to be configurable to avoid writing into the watched project directory (which triggers unnecessary file-watcher events).
Test plan
npm run buildcompiles cleanlyPORT=3000 node server/dist/index.jsstarts on port 3000CODEMAP_STATE_FILE=/tmp/state.json node server/dist/index.jswrites state to specified pathhttp://localhost:5174/hotelserves the React app/api/*🤖 Generated with Claude Code