This guide explains how to deploy the map comparison application with the Naver Directions API proxy.
Vercel provides serverless functions that work seamlessly with this application.
-
Install Vercel CLI (optional)
npm install -g vercel
-
Set Environment Variables in Vercel Dashboard
- Go to your project settings
- Add the following environment variables:
VITE_GOOGLE_MAPS_API_KEYVITE_NAVER_MAPS_CLIENT_IDVITE_NAVER_MAPS_CLIENT_SECRETVITE_KAKAO_MAP_APP_KEYVITE_API_BASE_URL(leave empty or set to your deployment URL)
-
Deploy
vercel
-
How it works
- The serverless function in
/api/directions.jshandles the proxy - Vercel automatically routes
/api/directionsto the serverless function - No separate backend server needed!
- The serverless function in
Netlify also supports serverless functions (called Netlify Functions).
-
Push your code to GitHub
git add . git commit -m "Prepare for Netlify deployment" git push origin main
-
Connect to Netlify
- Go to https://app.netlify.com
- Click "Add new site" → "Import an existing project"
- Choose "Deploy with GitHub"
- Select your repository
- Build settings (auto-detected):
- Build command:
npm run build - Publish directory:
dist - Functions directory:
netlify/functions(auto-detected)
- Build command:
-
Set Environment Variables
- Go to Site settings → Environment variables
- Add the following variables:
VITE_GOOGLE_MAPS_API_KEY= your Google Maps API keyVITE_NAVER_MAPS_CLIENT_ID= your Naver client IDVITE_NAVER_MAPS_CLIENT_SECRET= your Naver client secretVITE_KAKAO_MAP_APP_KEY= your Kakao app key- Note:
VITE_API_BASE_URLis NOT needed (auto-detected)
-
Deploy
- Click "Deploy site"
- Netlify automatically builds and deploys your site
- Every push to
mainbranch triggers automatic redeployment
-
Install Netlify CLI
npm install -g netlify-cli
-
Login to Netlify
netlify login
-
Build and Deploy
# Build the project npm run build # Deploy to production netlify deploy --prod
-
Set Environment Variables
- Go to Netlify Dashboard → Site settings → Environment variables
- Add the same variables as Method A
- The function in
/netlify/functions/directions.jshandles the proxy netlify.tomlredirects/api/*to/.netlify/functions/*- Code automatically detects production environment and uses relative path
/api/directions
If you prefer to run a separate backend server (e.g., on Railway, Render, or AWS):
-
Deploy the backend server (
server.js)- Use a platform like Railway, Render, Heroku, or AWS EC2
- Set environment variables on the platform
- Note the deployed URL (e.g.,
https://your-backend.railway.app)
-
Update frontend environment variable
- Set
VITE_API_BASE_URL=https://your-backend.railway.app
- Set
-
Deploy the frontend
- Deploy to Vercel, Netlify, or any static hosting
- Set all environment variables
| Variable | Required | Description |
|---|---|---|
VITE_GOOGLE_MAPS_API_KEY |
Yes | Google Maps Platform API key |
VITE_NAVER_MAPS_CLIENT_ID |
Yes | Naver Maps Client ID |
VITE_NAVER_MAPS_CLIENT_SECRET |
Yes | Naver Maps Client Secret (backend/serverless only) |
VITE_KAKAO_MAP_APP_KEY |
Yes | Kakao Map App Key |
VITE_API_BASE_URL |
No | Leave empty for Netlify/Vercel (auto-detected). Only needed for separate backend server. |
# Terminal 1: Run the proxy server
npm run dev:server
# Terminal 2: Run the frontend
npm run devEnvironment: .env with VITE_API_BASE_URL=http://localhost:3003
No need to run a separate server! The serverless function handles it.
Environment variables to set:
VITE_GOOGLE_MAPS_API_KEYVITE_NAVER_MAPS_CLIENT_IDVITE_NAVER_MAPS_CLIENT_SECRETVITE_KAKAO_MAP_APP_KEY
Do NOT set VITE_API_BASE_URL - the code automatically uses /api in production, which routes to the serverless function.
After deployment, test the Naver Directions API by:
- Go to the
/simulationpage - Set a start point and end point
- Check if the route is fetched successfully
- Look for any CORS errors in the browser console
- Make sure the serverless function includes CORS headers
- Check that environment variables are set correctly
- Vercel: Check that
vercel.jsonis in the root directory - Netlify: Check that
netlify.tomlis in the root directory - Verify the function files are in the correct directories
- Double-check environment variables in the deployment dashboard
- Make sure
VITE_NAVER_MAPS_CLIENT_SECRETis set (it's used by the backend)
For the easiest deployment experience, we recommend Vercel because:
- ✅ Zero configuration needed
- ✅ Automatic serverless function detection
- ✅ Free tier is generous
- ✅ Excellent performance
- ✅ Built-in environment variable management