Skip to content

Has anyone faced an issue with JWT access requiring a secret or public key, even though the keys are present in Docker #583

@aravindhfinix

Description

@aravindhfinix

🛠 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions