This guide walks you through deploying the Amazon Listing CLI to Vercel to securely store environment variables and optionally expose API endpoints.
- Vercel account (sign up at https://vercel.com)
- Vercel CLI installed globally:
npm install -g vercel - All environment variables from your
.envfile
npm install -g vercelvercel loginFrom the project root directory:
vercelFollow the prompts:
- Set up and deploy? Y
- Which scope? Select your account/organization
- Link to existing project? N (first time)
- What's your project's name? amazon-listing-cli (or keep default)
- In which directory is your code located? ./ (press Enter)
- Want to override settings? N (press Enter)
After the initial deployment, you need to add your environment variables. You can do this in two ways:
- Go to your project on Vercel: https://vercel.com/dashboard
- Click on your amazon-listing-cli project
- Go to Settings → Environment Variables
- Add each variable from your
.envfile:
| Variable Name | Value | Environment |
|---|---|---|
AMAZON_CLIENT_ID |
amzn1.application-oa2-client.YOUR_CLIENT_ID |
Production |
AMAZON_CLIENT_SECRET |
amzn1.oa2-cs.v1.YOUR_CLIENT_SECRET |
Production |
AMAZON_REFRESH_TOKEN |
Atzr|YOUR_REFRESH_TOKEN |
Production |
AMAZON_REGION |
us-east-1 |
Production |
AMAZON_MARKETPLACE_ID |
ATVPDKIKX0DER |
Production |
AMAZON_SELLER_ID |
YOUR_SELLER_ID |
Production |
AMAZON_SANDBOX |
false |
Production |
VERCEL_BLOB_TOKEN |
vercel_blob_rw_YOUR_TOKEN |
Production |
- Click Save after adding each variable
# Set each environment variable
vercel env add AMAZON_CLIENT_ID production
vercel env add AMAZON_CLIENT_SECRET production
vercel env add AMAZON_REFRESH_TOKEN production
vercel env add AMAZON_REGION production
vercel env add AMAZON_MARKETPLACE_ID production
vercel env add AMAZON_SELLER_ID production
vercel env add AMAZON_SANDBOX production
vercel env add VERCEL_BLOB_TOKEN productionWhen prompted, paste the value for each variable.
After adding environment variables, redeploy to apply them:
vercel --prodYour deployment includes a health check endpoint to verify environment variables are loaded:
curl https://your-project-name.vercel.app/api/healthExpected response:
{
"status": "healthy",
"service": "Amazon Listing CLI API",
"timestamp": "2025-10-10T...",
"env": {
"hasAmazonCredentials": true,
"hasVercelBlob": true,
"region": "us-east-1",
"sandbox": "false"
}
}amazon-listing-cli/
├── vercel.json # Vercel configuration
├── .vercelignore # Files to exclude from deployment
├── api/ # Vercel serverless functions
│ └── health.ts # Health check endpoint
├── cli/ # CLI tool (not deployed)
├── api/ # SP-API integration (shared code)
└── production-listings/ # Listings data (not deployed)
- The
api/folder at the root → Serverless functions - Build output (
dist/) → Static files - Configuration files (
vercel.json)
.envfiles (security)node_modules(rebuilt on Vercel)production-listings/images(too large, use Vercel Blob)- Debug and example files
✅ Secure: Environment variables in Vercel are encrypted and never exposed in client-side code
✅ Safe: Your .env file is gitignored and not deployed
✅ Accessible: Variables are available to serverless functions at runtime
The CLI tool continues to work locally with your .env file:
npm start -- list --filter "MPA-DTM"Environment variables in Vercel are for API endpoints and future web interfaces.
To update an existing environment variable:
- Via Dashboard: Go to Settings → Environment Variables → Edit
- Via CLI:
vercel env rm AMAZON_SANDBOX production vercel env add AMAZON_SANDBOX production # Enter new value when prompted
Then redeploy:
vercel --prod# Check build logs
vercel logsCommon issues:
- Missing dependencies: Run
npm installlocally first - TypeScript errors: Run
npm run buildlocally to debug
- Verify variables are set:
vercel env ls - Check they're assigned to Production environment
- Redeploy after adding variables:
vercel --prod - Test health endpoint:
curl https://your-url.vercel.app/api/health
- Ensure
api/health.tsis deployed - Check Vercel deployment logs
- Verify
vercel.jsonconfiguration is valid
- Deploy to Vercel
- Add all environment variables
- Test health endpoint
- Consider adding more API endpoints for listing operations
- Set up custom domain (optional)