Problem: The public and .next/static folders are not being copied to the standalone build directory in Railway. This causes the app to fail when trying to serve static assets (images, CSS, JS chunks).
Evidence:
- Railway logs show app starts successfully
- But when checking the standalone directory:
publicand.next/staticare missing - This causes 404 errors for all static assets
Fix Applied:
✅ Updated nixpacks.toml to copy these folders after build:
[phases.build]
cmds = [
"npm run build",
"cp -r public .next/standalone/public || true",
"cp -r .next/static .next/standalone/.next/static || true"
]Action Required: Commit and push this change to trigger a new Railway deployment.
Problem: NEXTAUTH_URL environment variable is not set in Railway.
Current Environment Variables:
- ✅
DATABASE_URL- Set correctly - ✅
NEXT_PUBLIC_REOWN_PROJECT_ID- Set correctly - ✅
NEXT_PUBLIC_APP_URL- Set tohttps://neetme-production.up.railway.app/ - ❌
NEXTAUTH_URL- MISSING - ❌
NEXTAUTH_SECRET- MISSING
Fix Required: Add these environment variables in Railway dashboard:
- Go to Railway dashboard → Your project → Variables
- Add:
NEXTAUTH_URL=https://neetme-production.up.railway.app(no trailing slash)NEXTAUTH_SECRET= Generate with:openssl rand -base64 32
Note: Even though you're using Reown for auth, NEXTAUTH_URL and NEXTAUTH_SECRET are still used for session management.
-
Commit and push the nixpacks.toml fix:
git add nixpacks.toml git commit -m "Fix: Copy public and static folders to standalone build" git push -
Add missing environment variables in Railway:
- Go to Railway dashboard
- Project → Variables
- Add
NEXTAUTH_URL=https://neetme-production.up.railway.app - Add
NEXTAUTH_SECRET= (generate withopenssl rand -base64 32)
-
Wait for Railway to redeploy (automatic after push)
-
Verify the fix:
# Check logs after deployment railway logs -s neetme --tail 50 # Verify static files are present railway run -s neetme sh -c "ls -la .next/standalone/public .next/standalone/.next/static"
- ✅ Build process completes successfully
- ✅ App starts without errors
- ✅ Database connection is configured
- ✅ Reown project ID is set correctly
- ✅ Railway CLI is connected and working
To test the fix locally before deploying:
# Build with the fix
npm run build
# Copy static files (simulating nixpacks.toml)
cp -r public .next/standalone/public
cp -r .next/static .next/standalone/.next/static
# Test start locally
npm startThen visit http://localhost:3000 to verify static assets load correctly.