Generate and configure the .env file env-file

The .env is a special file that is not part of the sample module, but is important for use in your Adobe Developer App Builder application. This file contains secrets and other information. Avoid committing this file to any code repository.

Who is this video for?

  • Developers new to Adobe Commerce with limited experience using Adobe App Builder who wants to learn about the .env file.

Video content

  • Introduction to the .env file and its purpose
  • How to generate the .env file
  • How to append the file to add new secrets
  • Avoid committing this file because it contains sensitive information
In this video, we’ll talk about the .env file. To be able to run the application locally, deploy changes to App Builder, the .env file should be configured correctly. This file contains the needed secrets to connect to the developer console, as well as the secrets to connect to third parties, such as Commerce Instance in the context of this sample app.
Start by generating the .env file, running the aio app use command. The command will prompt you to select your project, and workspace, and the organization you’re logged into. Once done, the .env file will be created with the needed secrets to connect to your project on App Builder. Append the file was the additional secrets. For example, by adding the commerce URL, consumer key and consumer secret, access token and token secret to connect to an Adobe Commerce instance, It’s important to keep in mind that this file is for local use only. Make sure not to commit this file to your repository to avoid security issues, publishing secrets by mistake. To deploy using GitHub for CI/CD purposes, App Builder provides a way to configure credentials based on the GitHub secrets of your repository. Details can be found in the App Builder documentation, accessing the link on the screen.

Code Sample

# Specify your secrets here
# The .env file must not be committed to source control
## Adobe I/O Runtime credentials
## Adobe I/O Console service account credentials (JWT) Api Key

# You can include some commerce OAUTH credentials too, our sample module will use this

You can see these static values being used in the sample module in file actions/commerce.index.js.

        const oauth = getCommerceOauthClient(
                url: params.COMMERCE_BASE_URL,
                consumerKey: params.COMMERCE_CONSUMER_KEY,
                consumerSecret: params.COMMERCE_CONSUMER_SECRET,
                accessToken: params.COMMERCE_ACCESS_TOKEN,
                accessTokenSecret: params.COMMERCE_ACCESS_TOKEN_SECRET