Do I have to add shopify_api_key as an Heroku variable or the proper key when deploying to Heroku

Do I have to add shopify_api_key as an Heroku variable or the proper key when deploying to Heroku

Bigjjjim
Shopify Partner
12 0 3

Hi there, 

I followed the new SHopify CLI 3.0 tutorial to create apps. When uploading, the documentation states to create this heroku.yml file with this content: 

build:
docker:
web: Dockerfile
config:
SHOPIFY_API_KEY: <SHOPIFY_API_KEY>

 

Then populate Heroku env with variables such as keys, host, etc

At first, I left the heroku.yml exactly like this, thinking it would be filled up from Heroku env. But when testing the <SHOPIFY_API_KEY> would show in the url and the app was not working.

So, I replaced it in this file with the real value to see if it worked, it did. 

Can it be that my app was not correctly fetching the Heroku variable or do we actually need to add the key there manually? 

Best, 
Jeremie

Replies 8 (8)

Mircea_Piturca
Shopify Partner
1548 44 349

I noticed the same thing. I was expecting the heroku.yml variables to be passed to docker. It looks like it only works when hard coded.

 

Poor documentation on CLI and Docker, all is a bit of a mess

 

Finally—Add variant descriptions to your products
Bigjjjim
Shopify Partner
12 0 3

I agree!

mannenson
Shopify Partner
20 1 10

Realised same thing today. How do you guys handle different environments when api key is hard coded? For example an heroku pipeline with a test stage for example MyApp-test (using credentials from MyApp-test in shopify) and MyApp-prod (using credentials from MyApp-prod in Shopify) the api key is needed to change.

rycastaneda
Shopify Partner
2 0 0

Encountering this issue as well, it seems that heroku.yml supplies the env variable to the dockerfile. This is pretty annoying needing to commit sensitive api keys for deployments

ampsy
Shopify Partner
3 0 0

I'm having the same issue. Frustrating that the tutorial doesn't address this.

remy727
Shopify Partner
44 2 26
SHOPIFY_API_KEY in heroku.yml file is being used on FrontEnd.
You can check web/frontend/vite.config.js
 
Heroku SHOPIFY_API_KEY env is being used on Backend.
You can check web/config/initializers/shopify_app.rb if you are using Shopify Rails App template.
Looking for a Shopify App developer? Please contact me at remy.wang727@gmail.com

buzali
Shopify Partner
2 0 1

We are having the same issue, can you guys share how you solved this to avoid hardcoding the Shopify key in the heroku.yml file?

remy727
Shopify Partner
44 2 26

No way to avoid hardcoding since SHOPIFY_API_KEY in heroku.yml file is build-time environment variable 

My colleague spoke with the Heroku team before and it looks like you need to build your images and push them yourself vs. using the heroku.yml file

Looking for a Shopify App developer? Please contact me at remy.wang727@gmail.com