Logs on prod to debug with specific messages
1heroku logs --source app --tail --app app-name-prod | grep "DINHANHTHI"
1// On backend
2Logger.debug('DINHANHTHI something else...')
List all environment variables on herolu to local terminal
1heroku config --app app-name
Problem only on production when you use multiple dynos
The big different between dev and prod may come from the settings of using 1 or many dynos (sub processes). Your app may use something like
node-cache
to store in a short term something and then want to get back later. However, in the prod mode, between 2 different requests, they may use 2 different dynos for the task. That’s why the things you stored in cache from 1 dyno cannot be found in another dyno. This problem doesn’t happen in the dev mode because we usually use only 1 dyno.You can check in the logs, there will be something like
app[web.1]
or app[web.2]
at the beginning of each log message. They indicate the corresponding dyno they are using.One solution for you is using a “global cache” addons. There are heroku-redis (limit connections even with paid), MemCachier (no limit connections with paid).