If you run pnpm run prod-local and test at http://localhost:3001, you'll encounter:
CORS Errors:
Access to fetch at 'http://local.statbus.org:3010/rest/rpc/auth_status' from origin 'http://localhost:3001' has been blocked by CORS policy
Why this happens:
- App runs on
localhost:3001(different origin) - API calls go to
local.statbus.org:3010(different origin) - Browser blocks cross-origin requests
- Next.js proxy rewrites only work in development mode
- Production builds expect unified URL architecture
# Stop any running app
./devops/manage-statbus.sh stop app
# Rebuild with latest changes
docker compose build app --no-cache
# Start production-like environment
./devops/manage-statbus.sh start app
# Test at unified URL
open http://local.statbus.org:3010Why this works:
- ✅ Uses unified URL (
local.statbus.org:3010for everything) - ✅ Caddy handles
/restAPI forwarding - ✅ No CORS issues (same origin)
- ✅ Exact production architecture
- ✅ Real production builds
If you see the page stuck on "Loading application..." at /login after successful authentication:
Root Cause: Navigation deadlock between Next.js router and page rendering
- Navigation machine commands
router.push('/') - Root page blocks rendering on data loading
- Next.js waits for page to render before completing navigation
- Navigation machine waits for pathname change
- Deadlock occurs
How to Test Locally:
- Use Docker:
./devops/manage-statbus.sh start app - Open
http://local.statbus.org:3010in browser - Enable debug:
localStorage.setItem('debug', 'true') - Login and observe if it hangs at
/login
Console Logs to Watch:
[DEBUG] [nav-machine:redirectingFromLogin] Redirecting away from /login to /- If URL stays at
/login→ bug reproduced - If URL changes to
/→ navigation completed successfully
Database Connection Issues:
# Check all services
docker compose ps
# Should show:
# statbus-local-db - healthy
# statbus-local-rest - running
# statbus-local-proxy - running
# statbus-local-app - runningIf services aren't healthy:
# Check logs
docker compose logs db --tail=50
docker compose logs rest --tail=50
docker compose logs app --tail=50
# Restart services
./devops/manage-statbus.sh restartMissing .env file:
ERROR: ../.env file not found!
Please run: ./devops/manage-statbus.sh generate-config
Solution:
./devops/manage-statbus.sh generate-configDNS resolution issues:
# Test DNS resolution
host local.statbus.org
# Should return: local.statbus.org has address 127.0.0.1
# If not working, add to /etc/hosts:
echo "127.0.0.1 local.statbus.org" | sudo tee -a /etc/hostsFor navigation/auth/state machine issues:
# 1. Make code changes
# 2. Rebuild container (takes ~2-3 minutes)
docker compose build app --no-cache
# 3. Start and test
./devops/manage-statbus.sh start app
# 4. Test at unified URL
open http://local.statbus.org:3010// In browser console
localStorage.setItem('debug', 'true')
// Reload page to see detailed state machine logs# Test if app responds
curl -I http://local.statbus.org:3010/
# Should return:
# HTTP/1.1 200 OK (or 307 redirect to /login)| Issue Type | Use | Access URL |
|---|---|---|
| Navigation, auth, state machines | Docker | http://local.statbus.org:3010 |
| API calls, data loading | Docker | http://local.statbus.org:3010 |
| Production build verification | Docker | http://local.statbus.org:3010 |
| Bundle size analysis | Either | localhost:3001 or local.statbus.org:3010 |
| Quick build test | pnpm run prod-local |
http://localhost:3001 |
| Development | pnpm run dev |
http://localhost:3000 |
The key insight is that STATBUS uses a unified URL architecture in production:
- Single domain handles both app and API
- Caddy proxy routes
/rest/*to PostgREST - This eliminates CORS issues and matches production exactly
When testing production issues, always use Docker to get this architecture right.