ARCHIVED: Historical document. Dev environment on gate server no longer exists. Only local and prod environments are active.
Date: 2026-01-21 Status: Complete Migration: Path-based → Subdomain-based routing
Successfully migrated development environment from path-based URLs to subdomain-based URLs.
- Backend API:
https://legal.org.ua/development/api/* - Frontend:
https://legal.org.ua/development/ - OAuth Callback:
https://legal.org.ua/development/auth/callback
- Backend API:
https://dev.legal.org.ua/api/* - Frontend:
https://dev.legal.org.ua/ - OAuth Callback:
https://dev.legal.org.ua/auth/callback
File: <deployment-root>/docker-compose.dev.yml
Changed Environment Variables:
# Backend (secondlayer-app-dev)
GOOGLE_CALLBACK_URL: https://dev.legal.org.ua/auth/google/callback
FRONTEND_URL: https://dev.legal.org.ua
ALLOWED_ORIGINS: https://dev.legal.org.ua
# Frontend (lexwebapp-dev)
VITE_API_URL: https://dev.legal.org.ua/apiBackup: Original file had these set to:
https://legal.org.ua/development/auth/callbackhttps://legal.org.ua/development
docker compose -f docker-compose.dev.yml up -d app-dev
docker compose -f docker-compose.dev.yml up -d lexwebapp-devRecreated containers:
secondlayer-app-dev- Backend API serverlexwebapp-dev- React frontend
ssh gate "docker exec secondlayer-app-dev env | grep -E 'FRONTEND_URL|ALLOWED_ORIGINS|GOOGLE_CALLBACK'"Output:
ALLOWED_ORIGINS=https://dev.legal.org.ua
FRONTEND_URL=https://dev.legal.org.ua
GOOGLE_CALLBACK_URL=https://dev.legal.org.ua/auth/callback
curl -s https://dev.legal.org.ua/health | jqOutput:
{
"status": "ok",
"service": "secondlayer-mcp-http",
"version": "1.0.0"
}curl -s -H "Authorization: Bearer <API_KEY>" https://dev.legal.org.ua/api/tools | jqWorking endpoints:
GET /health- Health check ✅GET /api/tools- List MCP tools ✅POST /api/tools/:toolName- Execute tool ✅- Authentication working with Bearer token ✅
Environment Variable: SECONDARY_LAYER_KEYS
Dev API Key: REDACTED_SL_KEY_LOCAL
Usage:
curl -H "Authorization: Bearer REDACTED_SL_KEY_LOCAL" \
https://dev.legal.org.ua/api/tools##REMOVED2
Current Status:
The OAuth callback URL has been updated in the backend, but you must also update it in Google Cloud Console.
Steps Required:
- Go to Google Cloud Console - Credentials
- Select your OAuth 2.0 Client ID (the one with ID:
323273425312-4chgdc3...) - Under "Authorized redirect URIs", add:
Note: The URL must include
https://dev.legal.org.ua/auth/google/callback/googlein the path! - Save changes
- Optional: Remove old URI:
https://legal.org.ua/development/auth/callback
Until this is done:
- Google OAuth login on dev.legal.org.ua will fail with "redirect_uri_mismatch" error
- API key authentication will continue to work
Container: lexwebapp-dev (port 8091)
Environment Variables:
NODE_ENV=development
VITE_API_URL=https://dev.legal.org.ua/apiStatic Build: If the frontend was built with the old URL, you may need to rebuild:
# On your local machine
cd <project-root>/lexwebapp
npm run build
# Copy to gate server
scp -r dist/* gate:/path/to/lexwebapp-build/
# Or rebuild in container
ssh gate "docker exec lexwebapp-dev npm run build"- Health endpoint responds
-
/api/toolsreturns tool list - Authentication with API key works
- CORS allows
https://dev.legal.org.uaorigin - OAuth callback URL configured in backend
- Visit
https://dev.legal.org.ua/in browser - Check browser console for API URL errors
- Test login with Google OAuth (requires Google Console update)
- Test API calls from frontend (search, patterns, etc.)
- PostgreSQL connected (secondlayer-postgres-dev:5432)
- Redis connected (secondlayer-redis-dev:6379)
- Qdrant connected (secondlayer-qdrant-dev:6333)
Symptom: Browser shows blocked by CORS policy
Check:
curl -v -H "Origin: https://dev.legal.org.ua" https://dev.legal.org.ua/api/toolsShould see:
Access-Control-Allow-Origin: https://dev.legal.org.ua
Access-Control-Allow-Credentials: true
Fix: Restart backend container if ALLOWED_ORIGINS not updated
Symptom: Google OAuth shows "redirect_uri_mismatch" error
Cause: Google Cloud Console doesn't have new callback URL
Fix: Add https://dev.legal.org.ua/auth/callback in Google Console (see steps above)
Symptom: {"error":"Unauthorized","message":"Invalid API key"}
Cause: Using wrong API key for dev environment
Fix: Use dev API key: REDACTED_SL_KEY_LOCAL
- Gate Containers Map - Container overview
- Dev Database Migration - Database setup
- Lexwebapp Backend Requirements - API requirements
⚠️ Update Google OAuth callback URL in Google Cloud Console- Test frontend at https://dev.legal.org.ua/
- Verify login flow works end-to-end
- Implement missing authentication endpoints (logout, refresh, profile)
- Create judges and lawyers database tables
- Build frontend if using old cached version
- Update stage environment with subdomain (stage.legal.org.ua)
- Remove old path-based nginx rules from production config
Migration Status: ✅ Complete (backend + frontend)
OAuth Status: