Overview
Netlify is the recommended deployment platform for Portal Ciudadano Manta, offering automatic GitHub deployments with built-in CI/CD, HTTPS, and excellent SPA support.Features Enabled
Continuous Deployment
Auto-deploy on push to main branch
HTTPS Automatic
Free SSL certificates
SPA Redirects
Vue Router support
Security Headers
Built-in security headers
Optimized Cache
Static asset caching
Deploy Previews
Preview PRs before merge
Option 1: Automatic Deployment from GitHub
Connect GitHub Repository
- Go to Netlify
- Click “Add new site” → “Import an existing project”
- Select “GitHub” and authorize Netlify
- Choose the
Portal-Ciudadano-Manta-webrepository
Configure Build Settings
Netlify will auto-detect settings, but verify:
- Build command:
npm run build - Publish directory:
dist - Node version:
20
Add Environment Variables
Before deploying, add your Supabase credentials:
- Go to Site settings → Environment variables
- Click “Add a variable”
- Add both variables:
Deploy Site
Click “Deploy site”. Netlify will:
- Clone your repository
- Install dependencies
- Run build command
- Publish to CDN
Option 2: Manual Deployment with Netlify CLI
Initialize Project
In your project directory:Follow the prompts:
- Create a new site or link existing
- Confirm build settings
Automatic Configuration
The project includes anetlify.toml configuration file (if present) that automatically configures:
Custom Domain Setup
Add Custom Domain
In Netlify dashboard:
- Go to Domain settings → Add custom domain
- Enter your domain (e.g.,
portal.manta.gob.ec)
Configure DNS
Netlify provides two options:Option A: Use Netlify DNS
- Transfer your domain nameservers to Netlify
- Netlify manages all DNS records
Continuous Deployment
Once connected to GitHub, Netlify automatically:- On push to main: Deploys to production
- On pull request: Creates deploy preview
- On merge: Updates production with preview build
Deploy Previews
Every pull request gets a unique preview URL:Build Environment
Node Version
Specify Node version inpackage.json or netlify.toml:
Build Logs
View detailed build logs:- Go to Deploys tab
- Click on a deployment
- View Deploy log
Troubleshooting
Build Fails
Problem: Build command exits with error Solutions:- Check build logs for specific error
- Verify
package.jsonscripts are correct - Ensure all dependencies are in
dependencies, notdevDependencies - Test build locally:
npm run build
404 on Page Refresh
Problem: Page refresh returns 404 error Solution: Add redirect rule (should be automatic withnetlify.toml):
Environment Variables Not Working
Problem:import.meta.env.VITE_SUPABASE_URL returns undefined
Solutions:
- Verify variables are added in Netlify dashboard
- Ensure variable names start with
VITE_ - Trigger new deployment after adding variables
- Check build logs for environment variable warnings
Supabase Connection Fails
Problem: “Failed to fetch” or CORS errors Solutions:- Add Netlify URL to Supabase allowed redirect URLs
- Check Supabase Site URL setting includes Netlify domain
- Verify environment variables are correct
Performance Optimization
Asset Optimization
Netlify automatically:- Compresses assets with Brotli/gzip
- Serves from global CDN
- Caches static assets
Cache Headers
Vite build automatically generates hashed filenames (app.abc123.js), enabling long-term caching:
Monitoring
Analytics
Enable Netlify Analytics:- Go to Analytics tab
- Enable analytics (paid feature)
- View page views, top pages, and traffic sources
Logs
View function logs and form submissions:- Go to Logs tab
- Filter by type and date
Next Steps
Environment Variables
Configure required variables
Supabase Setup
Complete backend configuration
