Overview
Deploy the FitAiid frontend Progressive Web App (PWA) to Vercel, a platform optimized for static sites and SPAs with automatic SSL, global CDN, and instant rollbacks.Estimated Time: 10 minutes
Difficulty: ⭐ (Very Easy)
Difficulty: ⭐ (Very Easy)
Prerequisites
Vercel Setup
1. Create Vercel Account
Sign Up
Navigate to vercel.com and click “Sign Up”
2. Import Project
Configure Environment Variables
The frontend needs to know where your backend API is located.Add API URL
Update Frontend Configuration
Configure API Endpoint
Ensure yourconfig.js points to the production backend:
Update API URL for Production
If your config still points to localhost, update it:Vercel automatically detects GitHub pushes and redeploys your application.
Deploy to Vercel
Progressive Web App Features
The FitAiid frontend is a full PWA with advanced features:Service Worker
Service Worker Configuration
Service Worker Configuration
The service worker handles offline functionality and push notifications:
frontend/service-worker.js
Offline-First Architecture
Cache Strategy
Assets are cached on first visit, enabling offline access to previously viewed pages.
Push Notifications
Web Push API integration allows real-time workout reminders and updates.
Background Sync
Failed API requests are queued and retried when connection is restored.
Install Prompt
Users can install FitAiid as a native app on mobile and desktop.
Frontend Architecture
Project Structure
Authentication Flow
Verify Deployment
Test Core Functionality
Test Login
Navigate to
/pages/login.html and test authentication:- Email:
[email protected] - Password:
Admin1234
You should be redirected to
/pages/home.html after successful login.Verify API Connection
Open browser DevTools (F12) → Network tab and confirm API requests go to your Railway URL:
Test Service Worker
DevTools → Application → Service WorkersVerify status shows: ✅ activated and running
Test PWA Installation
- Desktop (Chrome)
- Mobile (Android)
- Mobile (iOS)
- Look for the install icon in the address bar
- Click “Install FitAiid”
- Application opens in standalone window
Update CORS in Backend
Update Railway Environment Variables
Alternative: Update Code
Or update CORS directly in your backend code:backend/src/app.js
Troubleshooting
CORS errors in browser console
CORS errors in browser console
Symptom:Solution:
- Add your Vercel URL to backend CORS whitelist
- Ensure
credentials: trueis set in CORS config - Verify Railway backend has redeployed with new settings
Service Worker registration failed
Service Worker registration failed
Symptom:Solution:
- Service workers require HTTPS (Vercel provides this automatically)
- Verify
service-worker.jsis in the root offrontend/directory - Check browser console for syntax errors in service worker code
- Clear browser cache and hard reload (Ctrl+Shift+R)
API requests fail with 'undefined'
API requests fail with 'undefined'
Symptom:Solution:
- Verify
config.jsis loaded before other scripts in HTML:
- Check
config.jshas correct Railway URL - Test API URL manually in browser
Push notifications not working
Push notifications not working
Symptom:Solution:
- Check browser notification permissions (click padlock in address bar)
- Verify VAPID keys are configured in Railway backend
- Test on different browser (some block notifications by default)
- Check DevTools → Application → Service Workers for errors
Vercel deployment fails
Vercel deployment fails
Symptom:Solution:
- Verify Root Directory is set to
frontend/ - Ensure
index.htmlexists in frontend directory - Check for syntax errors in HTML/CSS/JS files
- Review Vercel build logs for specific errors
Custom Domain (Optional)
Add a custom domain to your Vercel deployment:Configure DNS
Add these records to your domain’s DNS:
| Type | Name | Value |
|---|---|---|
| A | @ | 76.76.21.21 |
| CNAME | www | cname.vercel-dns.com |
Performance Optimization
Edge Caching
Vercel’s global CDN caches static assets at edge locations for under 50ms response times.
Automatic Compression
Gzip and Brotli compression applied automatically to all assets.
Image Optimization
Use Vercel’s Image Optimization API for responsive images.
Code Splitting
Consider splitting large JavaScript files for faster initial loads.
Deployment Metrics
Monitor your deployment in Vercel Dashboard:- Deployment Frequency: Automatic on every GitHub push
- Build Time: ~30-60 seconds
- Global Latency: Under 50ms (edge locations)
- Uptime SLA: 99.99%
Next Steps
Configure Environment Variables
Learn about all the environment variables needed for FitAiid and how to obtain the API keys.