Azure / Azure/static-web-apps

How to pass custom environment variables to SWA Build

Open
#1,243 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

I would like to pass a custom environment variable to be by my React-based PWA. So far, this is how the app looks:

![Captura de pantalla 2023-08-10 a las 8 39 42](https://github.com/Azure/static-web-apps/assets/32467089/ac9bae47-df71-4a72-b49f-bf7defcb338b)

I followed [this tutorial](https://www.azurestaticwebapps.dev/blog/configuring-swa) and try to add `CUSTOM_ENV` and `PPP` in 2 different ways:
* `CUSTOM_ENV` was added as an environment variable from the Azure Portal:
Captura de pantalla 2023-08-10 a las 8 41 47

* `PPP` was added from my Github Action:

```
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_RED_SMOKE_0B4D0EC03 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: "api" # Api source code path - optional
output_location: "build" # Built app content directory - optional
env: # Add environment variables here
PPP: ppp
```

None of the methods work, as you can see from the following screenshot, `process.env` does not contain neither variable:

Captura de pantalla 2023-08-10 a las 8 46 02

Am I missing anything? How can I pass custom environment variables?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.