I followed the latest documentation for Strapi v3.x (strapi.io/documentation/v3.x/deployment/heroku.html) to deploy to Heroku, added Postgres db, deployed successfully, added admin user and created some dummy blog posts using the production admin UI (from my heroku project url).
But why does the posts not persist after the dyno stops? I understand that with images I would need something like Cloudinary (and I don’t need images), but with posts too? Doesn’t the posts just save to the postgres database?
I also noticed that when I make code changes in local and push it to heroku, it resets the entire app too and all my content is lost as well. How do I prevent that from happening in the future when I have many posts?
Did I do anything wrong? What did I miss? Apologies if this sound like a noob question as I’m not that good with node. Any general pointers would be appreciated, thank you!
Here’s my public repo: GitHub - jasonleow/strapi-lifelog
I believe the issue is Heroku isn’t applying the
NODE_ENV variable (I just recently modified those docs and made the assumption it automatically set
NODE_ENV=production can you adjust your heroku settings and set the environment variable?
If that works I’ll adjust our documentation.
Sorry am a bit of a noob, might need a little more handholding here. Which docs should I follow? Do you mean follow this youtube tutorial? Break up the DATABASE_URL and add host, port, username etc separately?
OK I researched a bit and tried this in terminal:
heroku config:set NODE_ENV=production
And then I pushed an update to heroku to reset things:
git push heroku master
And then I added a post in the admin UI. Will update again in an hour after the dyno restarts to see if the data persists.
YES!! It works! OMG after 4 days of debugging. Thanks for the help!
A bit of feedback: I read through a lot of questions in Stack Overflow having issues with Heroku deployment due to using SQlite via --quickstart. many solutions seem to revolve around not using --quickstart, going with postgres db from the start, and even not using strapi create project but use npm instead. Will be good to address these mix of solutions because it was super confusing as to what the problem was (and highlight this solution instead).
Yes thank you we do probably need to clarify that in our documentation.
Side note, glad the solution worked
Hello I am having the same issue. Its imposible to solve this! can someone help me?
I have all variables set but its not coneccting to the database. Where in the error???
Hello I’m havinf the same problem, can you help me to fix it?? where is the problem exactcly i am folowing all the documentations and no positive result.