Two parts: the API (Express + MySQL + chunk storage) and the frontend
(TanStack Start). The browser calls the API directly at VITE_API_URL; the
API allows the frontend's origin via CORS. There is no proxy in between.
Status on 27 Oct 2026: the Railway service behind
distributed-file-system-production.up.railway.appreturns "Application not found", anddistributed-file-system-seven.vercel.appreturnsDEPLOYMENT_NOT_FOUND. Both need to be set up again (steps below).
-
Create a service from this repo — root directory: repo root, start command
npm start(Node 20+). -
Add a MySQL 8 database and note its host/port/user/password/name.
-
Mount a persistent volume at
<app dir>/server/storage(on Railway:/app/server/storage). Without it, every redeploy deletes all file chunks. -
Set the environment variables (see
.env.example):Variable Value NODE_ENVproductionJWT_SECRETnode -e "console.log(require('crypto').randomBytes(64).toString('hex'))"ENCRYPTION_KEYnode -e "console.log(require('crypto').randomBytes(32).toString('hex'))"— back it up; losing it loses every fileDB_HOSTDB_PORTDB_USERDB_PASSWORDDB_NAMEfrom the MySQL service FRONTEND_URLe.g. https://distributed-file-system-seven.vercel.app(no trailing slash)CORS_ORIGIN_REGEXoptional, for preview deploys: ^https://distributed-file-system-[a-z0-9]+-nottastro\.vercel\.app$GOOGLE_CLIENT_IDGoogle Cloud OAuth "Web" client ID RESEND_API_KEY+SMTP_FROMfor email codes / reset links (resend.com; SMTP_FROMmust use a domain verified there)The server refuses to start in production without
JWT_SECRETandENCRYPTION_KEY— check the deploy log if it won't boot. -
First deploy only: create the tables and storage nodes once:
npm run db:initwith the same DB variables (Railway:railway run npm run db:init). It never drops tables, so re-running is safe. Later schema changes apply automatically on start-up. -
Check:
https://<api-host>/api/health→{"success":true,…}andhttps://<api-host>/api/auth/config→ showsgoogleClientIdandemailEnabled.
- Project root directory:
Frontend, framework preset: Other (the build emits Vercel's output format itself). - Environment variable:
VITE_API_URL=https://<api-host>/api(Production and Preview). It's read at build time, so redeploy after changing it. - Settings → Domains: make sure your production domain is assigned to the project (it currently isn't).
- If a deployment fails, open it in Vercel → Build Logs. The 26 Oct
deployment (
6f63cbc) failed on Vercel although the same build passes locally withVERCEL=1, so look for a project or account problem there.
Google Cloud Console → APIs & Services → Credentials → your OAuth client →
Authorized JavaScript origins: add the frontend URL (and
http://localhost:5173 for development). The frontend gets the client ID from
the API, so it only has to be set once, as GOOGLE_CLIENT_ID on the API.
When ENCRYPTION_KEY is set, chunks stored earlier without encryption are
encrypted in the background on start-up (log line Encrypt migration: …).
Set ENCRYPT_EXISTING_ON_BOOT=false to skip that and run
npm run encrypt:existing yourself. Both are safe to repeat or interrupt.
Never change ENCRYPTION_KEY once files are stored — key rotation isn't
supported yet.