Skip to content

Serve React frontend as static files from Express backend - #1

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

Serve React frontend as static files from Express backend#1
railway-app[bot] wants to merge 1 commit into
mainfrom
railway/code-change-iS4YWM

Conversation

@railway-app

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

Copy link
Copy Markdown
Contributor

Summary

Integrates the Vite/React frontend into the same Railway service as the Express backend. The backend's build script now installs frontend dependencies and runs vite build, copying the output into backend/frontend-dist. Express serves that directory as static files, with a catch-all route that returns index.html for client-side navigation. A railway.toml at the repo root sets the build and start commands so Railway runs from the repo root rather than the backend/ subdirectory. The frontend API base URL fallback is updated from the hardcoded localhost:5000 to a relative /api path, so it works correctly when served from the same origin in production without any environment variable.

Changes

  • Modified backend/index.js
  • Modified backend/package.json
  • Created railway.toml
  • Modified frontend/src/api/index.js

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