Questions and discussions about using the Shopify CLI and Shopify-built libraries.
Hi all,
Incredibly frustrating, i'm following the Shopify docs for deploying an app to Heroku for an app which was scaffolded and build with the Shopify CLI.
I'm following these docs:
https://shopify.dev/docs/apps/launch/deployment/deploy-web-app/deploy-to-heroku
And more generally for deploying to a hosting service:
https://shopify.dev/docs/apps/launch/deployment/deploy-web-app/deploy-to-hosting-service
Initially the app would just crash immediately and a Heroku error would display. After reading other people's issues with this, it turned out to be that the docs don't actually tell you to set up a HOST env variable on Heroku. Literally no mention of the HOST env variable whatsoever in the docs, so I added it via Heroku web admin, and suddenly the app no longer crashes! Hurray!
However, the current issue I have is that I now see a Shopify error as follows:
Additionally the logs show the following:
remote: Building the frontend app without an API key. The frontend build will not run without an API key. Set the SHOPIFY_API_KEY environment variable when running the build command.
I've followed the docs completely I just don't understand what to do at this point. How do I "Set the SHOPIFY_API_KEY environment variable when running the build command" when this is all supposed to be handled by the CLI's that are being used according to the docs?
Note: calling "shopify app env show" returns the expected environment variables and values.
Thanks for any advice
Mat
Solved! Go to the solution
This is an accepted solution.
Did you set the variables in your heroku app via the CLI or the dashboard > settings > config vars?
heroku config:set -a <my-app-name> \
SHOPIFY_APP_URL=https://<app-container>.herokuapp.com \
SHOPIFY_API_KEY=<SHOPIFY_API_KEY> \
SHOPIFY_API_SECRET=<SHOPIFY_API_SECRET> \
SCOPES=<SCOPES>
in your heroku tml file you can also add it there:
build:
docker:
web: Dockerfile
config:
SHOPIFY_API_KEY: <SHOPIFY_API_KEY>
This is an accepted solution.
Did you set the variables in your heroku app via the CLI or the dashboard > settings > config vars?
heroku config:set -a <my-app-name> \
SHOPIFY_APP_URL=https://<app-container>.herokuapp.com \
SHOPIFY_API_KEY=<SHOPIFY_API_KEY> \
SHOPIFY_API_SECRET=<SHOPIFY_API_SECRET> \
SCOPES=<SCOPES>
in your heroku tml file you can also add it there:
build:
docker:
web: Dockerfile
config:
SHOPIFY_API_KEY: <SHOPIFY_API_KEY>
Thank you, thank you thank you!!!
It was updating the heroku.yml file that made it work for me:
config:
SHOPIFY_API_KEY: <SHOPIFY_API_KEY>
I can't understand why this isn't documented on the page which describes how to deploy to Heroku!
Anyway thanks so much again, it's amazing to finally see my app hosted in a production environment and ready for deployment after so much hard work!
Mat