App reviews, troubleshooting, and recommendations
I created a Shopify APP and I can't use environment variables in development environment.
Variables written in the .env file can be used inside web/frontend directory
Actual behavior
process.env.VARIABLE_NAME is undefined
Steps to reproduce the problem
Console shows undefined instead of the expected value (TEST)
Note: I tried this in web/index.js where I put a new .env file and then did the same things above and it worked:
Then I did the same thing but now for the folder web/frontend where:
1. Install the package dotenv for web/frontend folder
2. import "dotenv/config" in web/frontend/index.jsx
3. Error: Uncaught TypeError: Cannot read properties of undefined (reading 'reduce')
And now I still cannot use env variables in web/frontend directory of my Shopify App.
How can you use env variables in any frontend?
Frontend code runs in the browser of the client. Not on any server. By fundamental definition, there is no concept of env variables for frontend tech.
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023