Why does my Shopify app say the SHOPIFY_API_KEY environment variable is missing?

seymur_crsp
Shopify Partner
65 4 10

I've created an app and now want to deploy it, but I can't.

Steps I take to start the production server:

npm run build
cd ./web
npm run serve

It serves the app, but when I open it in the admin, this message appears:
"Your app is running without the SHOPIFY_API_KEY environment variable. Please ensure that it is set when running or building your React app."

I definitely have that environment variable in .env file in the web folder.

What can I do ?

image.png

Replies 4 (4)

oscprofessional
Shopify Partner
15897 2378 3083

Hello @seymur_crsp 

Can you please elaborate on which server your App is hosted on?

 

And which Shopify template you are using?

 

Could you please clarify for me so that I can provide you with the solution?

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: pallavi@oscprofessionals.com | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free
seymur_crsp
Shopify Partner
65 4 10

Thanks. I later realized it was because dotenv wasn't configured properly, so the script couldn't read environment variables.

ronikmakwana
Shopify Partner
1 0 0

Can you tell me how you configured your dotenv  properly? It's very helpful to me.

seymur_crsp
Shopify Partner
65 4 10

Yeah, so there needs to be two env files, one in web folder, one in frontend folder. And SHOPIFY_API_KEY variable needs to be in both of those files. But when deploying to a real server this probably won't be needed