Common issues and solutions for The Inventory development.
Symptom: Browser shows No 'Access-Control-Allow-Origin' header is present
Most Common Cause: Backend isn’t running.
Solution:
cd src
python manage.py runserver
You should see a CORS warning box - this is normal in development and means all origins are allowed.
Still not working?
frontend/.env.local has: NEXT_PUBLIC_API_URL=http://localhost:8000/api/v1Production: Set CORS_ALLOWED_ORIGINS=https://your-domain.com in .env
To test on mobile or another computer:
ip addr show (Linux/Mac) or ipconfig (Windows)python manage.py runserver 0.0.0.0:8000http://YOUR_IP:3000Development CORS allows this automatically - no configuration needed!
Firewall blocking?
sudo ufw allow 3000 && sudo ufw allow 8000Migration errors:
cd src
rm db.sqlite3 # Development only!
python manage.py migrate
python manage.py createsuperuser
python manage.py seed_database --clear --create-default
PostgreSQL connection:
# Check .env format
DATABASE_URL=postgresql://username:password@host:port/database
Can’t login:
python manage.py createsuperuserpython manage.py seed_database --create-default“No tenant membership” error:
cd src
python manage.py seed_database --create-default
Symptom: Login works (200) but subsequent requests fail with 401 Unauthorized. Cookies appear in DevTools but aren’t being sent.
The issue depends on your domain setup:
Example: Frontend on vercel.app, Backend on onrender.com
Why it fails:
onrender.com won’t be sent to vercel.appSolution: Use token-based auth (Authorization header) instead of cookies
# Backend settings.py
JWT_COOKIE_DOMAIN = None # Disable cookie-based auth
Example: Frontend on theinventory.ndevuspace.com, Backend on api.theinventory.ndevuspace.com
Why it fails initially:
JWT_COOKIE_DOMAIN = None means cookies are only valid for exact domain matchSolution: Set cookie domain to shared parent domain
# Backend settings.py
JWT_COOKIE_DOMAIN = ".ndevuspace.com" # Leading dot = all subdomains
JWT_COOKIE_SECURE = True # Required for HTTPS
JWT_COOKIE_SAMESITE = "Lax" # Safe for same parent domain
Why this works:
.ndevuspace.com allows cookies to be shared between all subdomainstheinventory.ndevuspace.com to api.theinventory.ndevuspace.comFor shared parent domain setup:
Frontend: theinventory.ndevuspace.com
Backend: api.theinventory.ndevuspace.com
Parent: ndevuspace.com (shared)
JWT_COOKIE_DOMAIN=.ndevuspace.com
JWT_COOKIE_SECURE=True
JWT_COOKIE_SAMESITE=Lax
NEXT_PUBLIC_API_URL=https://api.theinventory.ndevuspace.com/api/v1
CORS_ALLOWED_ORIGINS = [
"https://theinventory.ndevuspace.com",
]
CORS_ALLOW_CREDENTIALS = True
access_token cookieDomain column shows .ndevuspace.com (with leading dot)Secure is checked (for HTTPS)/api/v1/auth/me/ requestCookie: access_token=... headerJWT_COOKIE_DOMAIN matches your domain setupCORS_ALLOW_CREDENTIALS = True in backendPort already in use:
# Find process
lsof -i :8000 # Linux/Mac
netstat -ano | findstr :8000 # Windows
# Kill it
kill -9 <PID> # Linux/Mac
taskkill /PID <PID> /F # Windows
Python environment issues:
deactivate
rm -rf venv
python3.12 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Node/Yarn issues:
cd frontend
rm -rf node_modules .next yarn.lock
yarn install
Tests not discovered?
Ensure you’re running from the src/ directory:
cd src
python manage.py test
Want to run only seeder tests?
python manage.py test tests.seeders
Want to run a specific test?
python manage.py test tests.api.test_auth.AuthTestCase.test_login
Understanding test output:
The custom test runner automatically excludes seeder tests by default. You’ll see:
python manage.py test (seeders excluded)python manage.py test tests.seeders (seeders only)This is intentional — seeder tests are only included when explicitly requested.
# Backend
cd src
python manage.py runserver # Start
python manage.py runserver 0.0.0.0:8000 # Network access
python manage.py migrate # Migrations
python manage.py createsuperuser # Admin user
# Frontend
cd frontend
yarn install # Dependencies
yarn dev # Start
yarn build # Production build
# Database
python manage.py dbshell # Database shell
python manage.py shell # Django shell