This guide shows how to deploy the FISE Fastify backend to Vercel using the Vercel Dashboard.
You must deploy from the Vercel Dashboard - this ensures proper monorepo configuration and workspace linking.
- Go to Vercel Dashboard
- Click "Add New..." → "Project"
- Import your Git repository (GitHub, GitLab, or Bitbucket)
- Select the repository containing this backend
-
Root Directory:
⚠️ CRITICAL- Click "Edit" next to Root Directory
- Set to:
backend-fastify - This tells Vercel to treat
backend-fastifyas the project root
-
Framework Preset:
- Select "Other" or leave as auto-detected
-
Build Command:
- Leave empty (no build needed for serverless functions)
-
Output Directory:
- Leave empty
-
Install Command:
- Leave empty (npm will auto-install from root)
-
Environment Variables (Optional):
- No environment variables required for basic setup
- Add any custom variables if needed
- Click "Deploy"
- Wait for deployment to complete
- Your API will be available at:
https://your-project.vercel.app
# Test health endpoint
curl https://your-project.vercel.app/health
# Test protected endpoint
curl https://your-project.vercel.app/api/demo/protected- Must be set to:
backend-fastify - This ensures Vercel uses the correct
vercel.jsonand workspace structure
{
"rewrites": [
{
"source": "/(.*)",
"destination": "/api/server.js"
}
],
"functions": {
"api/server.js": {
"maxDuration": 30
}
}
}What this does:
- Routes all requests to
/api/server.jsserverless function - Sets 30-second timeout for function execution
- Uses modern Vercel functions API (no
buildsproperty)
backend-fastify/
├── api/
│ └── server.js # Serverless function entry point
├── routes/ # Route handlers
├── utils/ # Utilities
├── server.js # Local dev server (not deployed)
└── vercel.json # Vercel configuration
-
Workspace Linking:
- Vercel runs
npm installinbackend-fastifydirectory - npm sees
"@fise-examples/shared": "file:../shared"inpackage.json - npm automatically installs the local shared package from
../shared - Shared package and its dependencies (including
fise) are installed
- Vercel runs
-
Serverless Function:
api/server.jsis deployed as a serverless function- All routes are handled by this single function
- Fastify instance is initialized once (singleton pattern)
-
Shared Package:
@fise-examples/sharedis resolved from../shareddirectory- All imports from
@fise-examples/sharedwork correctly
- Root directory set to
backend-fastifyin Vercel Dashboard - Deployment successful (check build logs)
- Health endpoint works:
/health - API endpoints respond correctly
- CORS configured (allows frontend access)
- Deployment Protection disabled (for public API access)
- Push changes to your Git repository
- Vercel automatically detects changes
- New deployment is triggered automatically
- Preview deployments created for pull requests
- Go to Vercel Dashboard → Your Project
- Click "Redeploy" button
- Select the branch/commit to deploy
Cause: Workspace not linked correctly
Solutions:
- Verify Root Directory is set to
backend-fastify(not root) - Check
package.jsonuses"file:../shared"(not"*") - Check build logs for npm install errors
- Ensure
shared/directory exists in repository
Cause: Using legacy builds property
Solution: ✅ Already fixed - vercel.json uses only functions property
Cause: Long-running operations
Solutions:
- Current timeout is 30 seconds (configured in
vercel.json) - For longer operations, upgrade to Vercel Pro (60s timeout)
- Optimize slow endpoints
Cause: Deployment Protection or CORS misconfiguration
Solutions:
- Disable Deployment Protection in Vercel Dashboard:
- Settings → Deployment Protection → Disabled
- Verify backend CORS allows all origins (already configured in code)
- Check
VITE_API_BASEin frontend points to correct backend URL
Cause: Incorrect configuration or missing files
Solutions:
- Verify Root Directory is
backend-fastify - Check build logs in Vercel Dashboard for specific errors
- Ensure
api/server.jsexists - Verify all route files are present
- Deploy Frontend: See frontend-react/DEPLOY.md
- Update Frontend API URL: Set
VITE_API_BASEto your backend URL - Test Integration: Verify frontend can connect to backend
- Monitor: Check Vercel Analytics for usage