Azure StaticWebApps and behavior of dotEnv to get environment variables

Viewed 15

Hi I created a basic project using Azure static web apps and added 2 env files in it ".env" and ".env.production". I observed all the new Azure staticwebapps were being started in "production environment" by default.

So let's say theres a key "REACT_APP_API_URL", which have different values in both the env files. I was able to switch keys using by setting the appropriate environment.

After that, I wanted to test if environment variables can override these .env files. So I in the pipeline I added the environment variable to modify the key.

trigger:
  - dev
pool:
  vmImage: ubuntu-latest
steps:
  - task: AzureStaticWebApp@0
    inputs:
      app_location: "" 
      output_location: "build"
    env:
      azure_static_web_apps_api_token: $(deployment_token)
      REACT_APP_API_URL: "Some value diff than .env and .env.prod"

It does override the .env files. Can someone kindly explain, how it is able to do that? I have checked Dot env package doc and I still dont understand which values take priority in case both the .env files and environment variables are present.

0 Answers
Related