-
Notifications
You must be signed in to change notification settings - Fork 204
Description
🛠 JWT Setup Debug Notes
I generated the keys using yarn generate:keys
.
I created a .env
file based on example.env
.
I started Docker.
-docker-compose up -d
seeded the data
-docker-compose exec apis yarn migrate:seed
Initially, I faced errors in the Mongo and Redis containers.
🔧 I fixed this by updating the DB connection URLs in the .env
file — specifically, I changed the hostnames to match the container names.
this has to be changed from host to container name mongo
mongo-init:
image: mongo:latest
restart: 'no'
depends_on:
mongo:
condition: service_healthy
networks:
- app-network
command: >
bash -c "
echo 'Waiting for MongoDB instance to be ready...' &&
mongosh --host mongo:27017 --eval '
config = {
"_id": "rs0",
"members": [
{ "_id": 0, "host": "mongo:27017", "priority": 1 }
]
};
rs.initiate(config);
rs.status();' &&
echo 'Single-node replica set initialized successfully. Container will exit now.'
"
deploy:
restart_policy:
condition: none
After that, Mongo and Redis connected successfully, and Docker was running fine.
However, when hitting an API, the JWKS server could not be reached.
🔧 I fixed that by updating the
AUTH_JWT_JWKS_URI
to:
http://jwks-server/.well-known/jwks.json
That resolved the JWKS connection error, but then I encountered this JWT error:
Error: secret or public key must be provided
This prevented JWT authentication from working.
✅ Summary of Fixes Done
✔️ Keys generated properly
✔️ .env
configured correctly
✔️ MongoDB & Redis containers fixed with proper hostnames
✔️ JWKS server hostname corrected
❌ Still stuck on JWT secret/public key not being recognized