Skip to content

Replace vite preview with proper HTTP server#5

Open
railway-app[bot] wants to merge 1 commit into
mainfrom
railway/code-change-7JaqFn
Open

Replace vite preview with proper HTTP server#5
railway-app[bot] wants to merge 1 commit into
mainfrom
railway/code-change-7JaqFn

Conversation

@railway-app
Copy link
Copy Markdown

@railway-app railway-app Bot commented Apr 5, 2026

Problem

The frontend service was returning 502 Bad Gateway because vite preview (invoked via npm run preview) is not designed for production use and was crashing immediately without output, failing to bind to the PORT environment variable reliably.

Solution

Added frontend/server.js, a zero-dependency Node.js HTTP server that serves the built dist folder, reads PORT from the environment (defaulting to 5173), binds to 0.0.0.0, and falls back to index.html for any unmatched path to support client-side routing. Updated the Dockerfile CMD from npm run preview to node server.js.

Changes

  • Created frontend/server.js
  • Modified frontend/Dockerfile

Generated by Railway

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.

0 participants