Deployment to Heroku: Missing Shopify API Key

Topic summary

Main issue: Deploying a Shopify CLI-generated app to Heroku failed due to missing environment variables, leading first to app crashes and then to a Shopify frontend build error.

Key events:

  • Initial crash fixed by manually adding the HOST environment variable in Heroku (not mentioned in the official docs).
  • Subsequent error: browser showed a Shopify error; logs warned, “Building the frontend app without an API key… Set the SHOPIFY_API_KEY environment variable.”
  • Clarification: Variables can be set via Heroku Dashboard (Settings > Config Vars), the Heroku CLI (heroku config:set -a …), or in heroku.yml under build.config.

Resolution (most recent update):

  • Adding SHOPIFY_API_KEY to heroku.yml (build.config) solved the build issue, and the app now runs in production.

Notes:

  • A screenshot of the Shopify error was referenced; logs were central to identifying the missing SHOPIFY_API_KEY.
  • The participant highlighted gaps in Shopify’s Heroku deployment docs (no mention of HOST and unclear guidance on setting SHOPIFY_API_KEY during build).

Status: Resolved; no remaining open questions.

Summarized with AI on December 19. AI used: gpt-5.

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

Did you set the variables in your heroku app via the CLI or the dashboard > settings > config vars?

heroku config:set -a 

in your heroku tml file you can also add it there:

```markup
build:
  docker:
    web: Dockerfile
  config:
    SHOPIFY_API_KEY:
1 Like

Thank you, thank you thank you!!!

It was updating the heroku.yml file that made it work for me:

config:
    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