Bước cuối cùng là deploy frontend Next.js 15 lên AWS Amplify với tích hợp GitLab để tự động deploy khi có code mới.
1. Check Frontend Structure
cd frontend
# Check package.json
cat package.json
# Should show Next.js 15
2. Test Frontend Locally
# Install dependencies
npm install
# Run development server
npm run dev
# Open http://localhost:3000
3. Build Frontend
# Build for production
npm run build
# Test production build
npm start
1. Go to AWS Amplify Console
2. Connect to GitLab
Screenshot: Amplify showing GitLab connection
3. Select Repository
everyonecookmain (or dev for development)1. App Name
App name: everyonecook-frontend
2. Build Settings
Amplify auto-detects Next.js, but verify:
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
- .next/cache/**/*
Screenshot: Amplify build settings for Next.js
3. Advanced Settings
Add environment variables:
NEXT_PUBLIC_API_URL=https://api.everyonecook.cloud
NEXT_PUBLIC_CDN_URL=https://cdn.everyonecook.cloud
NEXT_PUBLIC_USER_POOL_ID=us-east-1_ABC123
NEXT_PUBLIC_USER_POOL_CLIENT_ID=abc123def456
NEXT_PUBLIC_REGION=us-east-1
Screenshot: Amplify environment variables configuration
1. Start Deployment
Click “Save and deploy”
Amplify will:
2. Monitor Deployment
Watch deployment progress:
Screenshot: Amplify showing deployment in progress
3. Wait for Completion
Deployment takes 5-10 minutes.
Screenshot: Amplify showing successful deployment
1. Add Custom Domain
everyonecook.cloudeveryonecook.cloudwww.everyonecook.cloud2. DNS Configuration
Amplify automatically creates DNS records in Route 53:
everyonecook.cloud → A record → Amplify
www.everyonecook.cloud → CNAME → Amplify
3. SSL Certificate
Amplify automatically provisions SSL certificate via ACM.
4. Wait for DNS Propagation
Takes 5-15 minutes.
Screenshot: Amplify showing custom domain configured
1. Access Frontend
# Via Amplify domain
curl -I https://main.d1234567890.amplifyapp.com
# Via custom domain
curl -I https://everyonecook.cloud
# Should return 200 OK
2. Test Frontend Features
Screenshot: Browser showing EveryoneCook frontend live
1. Enable Auto-Deploy
Auto-deploy is enabled by default. When you push to GitLab:
git push origin main
Amplify automatically:
2. Configure Branch Deployments
Set up multiple environments:
Add dev branch:
dev branchdev.everyonecook.cloud
Screenshot: Amplify showing multiple branch deployments
1. Add SNS Notifications
2. Slack Integration (Optional)
1. Check Amplify Metrics
2. Enable CloudWatch Logs
# View Amplify build logs
aws amplify get-job \
--app-id d1234567890 \
--branch-name main \
--job-id 1
1. Add Redirects
Create amplify.yml in frontend root:
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
- .next/cache/**/*
customHeaders:
- pattern: '**/*'
headers:
- key: 'Strict-Transport-Security'
value: 'max-age=31536000; includeSubDomains'
- key: 'X-Frame-Options'
value: 'SAMEORIGIN'
- key: 'X-Content-Type-Options'
value: 'nosniff'
redirects:
- source: '/<*>'
target: '/index.html'
status: '404-200'
2. Commit and Push
git add amplify.yml
git commit -m "Add Amplify configuration"
git push origin main
Deployed Resources:
URLs:
Amplify Hosting:
Estimated Cost:
Issue: Build fails
# Check build logs in Amplify console
# Common issues:
# - Missing environment variables
# - Node version mismatch
# - Build command incorrect
Issue: Custom domain not working
# Check DNS propagation
dig everyonecook.cloud
# Check Route 53 records
aws route53 list-resource-record-sets \
--hosted-zone-id YOUR-ZONE-ID
Issue: Environment variables not working
# Ensure variables start with NEXT_PUBLIC_ for client-side
# Redeploy after adding variables
Congratulations! Your application is now fully deployed:
Proceed to Cleanup when you’re done testing, or start using your application!