Apart from following the instructions of this link https://www.gatsbyjs.org/docs/deploying-to-heroku/
No one has even mentioned that we also need to add that buildpack in the Heroku configuration as the image below. It’s inside the setting tab.
It took me a while to figure it out. I hope this will save you sometimes if you pump into the Application Error page after deployment.