Data: 2026-01-11T14:11:57-03:00
Objetivo: Deploy completo do backend (Railway) e frontend (Vercel)
-
backend/package.json- Configurado corretamente -
backend/server.js- Todas as rotas montadas -
backend/prisma/schema.prisma- Schema atualizado -
Chat/package.json- Build configurado - Gamification bugs corrigidos
- Trae Mode implementado
Gamification 500 error✅ RESOLVIDO- Backend error em produção (a investigar)
.metadataerror (não crítico)
# Database
DATABASE_URL=postgresql://...
# API Keys
GEMINI_API_KEY=your_key_here
MINIMAX_API_KEY=your_key_here
MINIMAX_GROUP_ID=your_group_id_here
HUGGINGFACE_ACCESS_TOKEN=your_token_here
# Services
RESEND_API_KEY=your_key_here
AWS_ACCESS_KEY_ID=your_key_here
AWS_SECRET_ACCESS_KEY=your_key_here
AWS_REGION=us-east-1
S3_BUCKET_NAME=your_bucket_name
# OAuth
DISCORD_CLIENT_ID=your_client_id
DISCORD_CLIENT_SECRET=your_secret
DISCORD_REDIRECT_URI=https://your-backend.railway.app/api/auth/discord/callback
GOOGLE_CLIENT_ID=your_client_id
GOOGLE_CLIENT_SECRET=your_secret
GOOGLE_REDIRECT_URI=https://your-backend.railway.app/api/auth/google/callback
# Frontend URL
FRONTEND_URL=https://your-app.vercel.app
# Node Environment
NODE_ENV=production
PORT=4000npm install && npx prisma generate && npx prisma db pushnpm startCriar arquivo backend/railway.toml:
[build]
builder = "NIXPACKS"
[deploy]
startCommand = "npm start"
restartPolicyType = "ON_FAILURE"
restartPolicyMaxRetries = 10VITE_API_BASE_URL=https://your-backend.railway.app- Framework Preset: Vite
- Build Command:
npm run build - Output Directory:
dist - Install Command:
npm install - Node Version: 20.x
Criar arquivo Chat/vercel.json:
{
"buildCommand": "npm run build",
"outputDirectory": "dist",
"framework": "vite",
"rewrites": [
{
"source": "/(.*)",
"destination": "/index.html"
}
],
"headers": [
{
"source": "/assets/(.*)",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=31536000, immutable"
}
]
}
]
}# Acessar logs
railway logs
# Logs em tempo real
railway logs --follow# Erro: Can't reach database server
# Solução: Verificar DATABASE_URL
# Rodar migration manualmente
railway run npx prisma db push# Erro: Cannot find module 'X'
# Solução: Verificar package.json e reinstalar
railway run npm install# Erro: EADDRINUSE
# Solução: Railway define PORT automaticamente
# Usar: process.env.PORT || 4000# Erro: CORS policy blocked
# Solução: Verificar FRONTEND_URL no .env
# E configuração CORS no server.js# Verificar logs específicos
railway logs | grep "500"
# Adicionar mais logging
console.error('[ERROR]', error.stack);# Backend
curl https://your-backend.railway.app/health
# Gamification
curl https://your-backend.railway.app/api/gamification \
-H "Authorization: Bearer YOUR_TOKEN"
# Trae Mode
curl https://your-backend.railway.app/api/trae/health \
-H "Authorization: Bearer YOUR_TOKEN"✅ GET /health
✅ POST /api/auth/login
✅ GET /api/gamification
✅ POST /api/chat
✅ GET /api/trae/tools
✅ POST /api/trae/execute
- Environment variables configuradas
- DATABASE_URL correto
- Prisma migrations rodadas
- Build bem-sucedido
- Server iniciado sem erros
- Health check respondendo
- Logs sem erros críticos
- VITE_API_BASE_URL configurado
- Build bem-sucedido
- Deploy completo
- Site acessível
- API calls funcionando
- Login funcionando
- Chat funcionando
# 1. Verificar logs
railway logs --tail 100
# 2. Verificar variáveis
railway variables
# 3. Rebuild
railway up --detach# 1. Verificar VITE_API_BASE_URL
echo $VITE_API_BASE_URL
# 2. Verificar CORS no backend
# server.js deve ter:
res.header("Access-Control-Allow-Origin", FRONTEND_URL);
# 3. Rebuild frontend
vercel --prod# Verificar se as correções foram deployadas
# Arquivos modificados:
# - backend/gamificationStore.js
# - backend/routes/gamification.js
# Verificar logs
railway logs | grep "gamification"cd backend
railway login
railway link
railway up
railway logs --followcd Chat
vercel login
vercel --prod
vercel logs# Commit todas as mudanças
git add .
git commit -m "fix: gamification serialization + trae mode implementation"
git push origin main
# Railway e Vercel fazem deploy automático- ✅ Gamification Fix - JSON serialization corrigida
- ✅ Trae Mode - Backend + Frontend completo
- ✅ Server.js - Rota
/api/traeadicionada - ✅ Prisma - Schema atualizado
backend/gamificationStore.js
backend/routes/gamification.js
backend/routes/trae.js
backend/services/traeMode/
backend/server.js
Chat/components/TraePanel.tsx
Chat/components/Sidebar.tsx
Chat/App.tsx
- Login funciona
- Chat funciona
- Gamification carrega sem 500
- Trae Mode aparece para admins
- Todas as APIs respondem
BACKEND (Railway):
[ ] git push origin main
[ ] Railway auto-deploy iniciado
[ ] Build completo (verificar logs)
[ ] Prisma migrations aplicadas
[ ] Server rodando
[ ] Health check OK
[ ] Testar endpoints principais
FRONTEND (Vercel):
[ ] git push origin main
[ ] Vercel auto-deploy iniciado
[ ] Build completo
[ ] Deploy bem-sucedido
[ ] Site acessível
[ ] Conecta ao backend
[ ] Login funciona
[ ] Chat funciona
VALIDAÇÃO:
[ ] Criar conta nova
[ ] Fazer login
[ ] Enviar mensagem
[ ] Verificar gamification
[ ] Abrir Trae Mode (admin)
[ ] Testar ferramentas
# Railway
railway rollback
# Vercel
vercel rollback# Railway - últimas 1000 linhas
railway logs --tail 1000 > railway-logs.txt
# Vercel - logs de build
vercel logs --follow- Railway Dashboard: https://railway.app/dashboard
- Vercel Dashboard: https://vercel.com/dashboard
- Logs em tempo real disponíveis em ambos
Status: 📋 PRONTO PARA DEPLOY
Execute os comandos e monitore os logs! 🚀