- ✅ Backend is running and healthy
- ✅
/healthendpoint works (200 OK) - ❌
/api/maps/places/autocompletereturns 502 Bad Gateway - ❌ CORS headers not present
This suggests the maps route itself might be erroring, or there's a proxy/Apache configuration issue.
Run the test script:
cd /root/stairs-new
bash test-maps-endpoint.shThis will test:
- Local endpoint (bypassing proxy)
- External endpoint (through Cloudflare)
- CORS headers
- OPTIONS preflight
- Backend logs
# Check recent logs
pm2 logs stairs-backend --lines 100 --nostream | grep -i -E "maps|places|autocomplete|error"
# Or watch logs in real-time
pm2 logs stairs-backend --lines 50Look for:
Google Maps API key not configurederrors- Database connection errors
- Route handler errors
- CORS errors
# Test directly on server
curl -v "http://localhost:5000/api/maps/places/autocomplete?input=test"
# Should return JSON response or error messageIf local works but external doesn't → Proxy/Apache issue If local fails → Backend route issue
# Check if route file exists
ls -la /root/stairs-new/backend/src/routes/maps.js
# Check if route is imported in index.js
grep -n "maps" /root/stairs-new/backend/src/index.js
# Should see something like:
# app.use('/api/maps', mapsRoutes);Since you're using Apache (httpd), check if the proxy is correctly forwarding /api/maps/* requests:
# Check Apache virtual host config
grep -r "ProxyPass.*api" /etc/apache2/sites-available/
# or
grep -r "ProxyPass.*api" /etc/httpd/conf.d/
# Look for something like:
# ProxyPass /api http://localhost:5000/api
# ProxyPassReverse /api http://localhost:5000/apiCommon issues:
- Proxy not forwarding
/api/maps/*correctly - Proxy stripping CORS headers
- Proxy timeout too short
- Proxy not handling OPTIONS requests
cd /root/stairs-new/backend
# Pull latest code (if using git)
git pull
# Restart backend to ensure latest code is running
pm2 restart stairs-backend
# Check it's running
pm2 logs stairs-backend --lines 20# Check GOOGLE_MAPS_API_KEY is set
grep "GOOGLE_MAPS_API_KEY" /root/stairs-new/backend/.env
# If missing or empty, that's the issue!
# The maps route requires this keyTemporarily add logging to maps route:
# Edit maps route
nano /root/stairs-new/backend/src/routes/maps.js
# Add at the start of the route handler:
router.get('/places/autocomplete', async (req, res) => {
console.log('📍 Maps autocomplete called:', req.query);
console.log('📍 Origin:', req.headers.origin);
try {
// ... rest of codeThen:
pm2 restart stairs-backend
pm2 logs stairs-backend --lines 0
# Try making a request and watch logsSymptom: Route returns 503 or error message Fix:
# Add to backend/.env
echo "GOOGLE_MAPS_API_KEY=your_key_here" >> /root/stairs-new/backend/.env
pm2 restart stairs-backendSymptom: Local works, external returns 502 Fix: Check Apache proxy configuration (see Step 5)
Symptom: 200 OK but no CORS headers Fix: Check Apache isn't stripping headers, ensure backend CORS middleware is running
Symptom: 404 or route not found
Fix: Verify app.use('/api/maps', mapsRoutes); is in backend/src/index.js
# 1. Test local endpoint
curl "http://localhost:5000/api/maps/places/autocomplete?input=test"
# 2. Test external endpoint
curl "https://stairs-api.astroraag.com/api/maps/places/autocomplete?input=test"
# 3. Test CORS
curl -I -H "Origin: https://portal.stairs.org.in" \
"https://stairs-api.astroraag.com/api/maps/places/autocomplete?input=test"
# 4. Check backend logs
pm2 logs stairs-backend --lines 50 | tail -20After fixes:
- Local endpoint works:
curl http://localhost:5000/api/maps/places/autocomplete?input=test - External endpoint works:
curl https://stairs-api.astroraag.com/api/maps/places/autocomplete?input=test - CORS headers present:
Access-Control-Allow-Origin: https://portal.stairs.org.in - No errors in backend logs
- Google Maps API key is set in
.env - Frontend can make requests (no CORS errors)
- Venue autocomplete works in UI
Run test-maps-endpoint.sh first to identify the exact issue!