We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Protecting Secrets

Moving a secret out of source code is only the first step. Local files that contain injected secrets also need to stay out of version control.

As a general rule, environment files should be ignored by version control.

.env*
!.env.example

That said, a .env.example file is conventionally committed with dummy examples of the values the app expects in .env.

APP_ORIGIN=http://localhost:3000
TICKET_PROVIDER_KEY=replace_with_your_ticket_provider_key

Developers can copy that template into a local .env file and supply their own values.

Node.js 24 can load a file through --env-file-if-exists=.env. Adding that flag to the local dev and start scripts loads .env when it exists without making the file mandatory. Shells and production environments can simply inject the variable directly.

Assignment

Bearly Secure requires runtime configuration, but its local scripts do not load .env yet. Add a safe local environment-file workflow.

  1. PAWPAL_API_KEY=replace_with_your_pawpal_api_key
    DOWNLOAD_SIGNING_KEY=replace_with_64_hex_characters
    APP_ORIGIN=http://localhost:3000
    
  2. --env-file-if-exists=.env
    
  3. openssl rand -hex 32
    
  4. git check-ignore .env
    
  5. npm run dev
    

Run and submit the CLI tests from the project root.