API deployed with React does not propagate environment variables to API
- Dominant language
- No language data
- Stars
- 346
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
I have a React app deploying to Azure Static Web Apps and I have a companion API to go with it in the form of a Function. They are deploying fine, but the variables I am setting in `env:` are not available to the Function. I have tried both Javascript and C#/.NET Functions. I am testing this by simply returning the serialized `process.env` (in Javascript) or `Environment.GetEnvironmentVariables` (in C#/.NET)
I am expecting the `KEY_VAULT_URL` and `CONFIG_API_TOKEN` variables to be available in my API.
The React SWA and API deploy correctly and both are functional -- but the two variables listed above are not set in the API's environment.
Below is my Github workflow. Please advise as to what I'm missing. I am very new to Github Workflows and React, so please be kind.
```yaml
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Build And Deploy Web App
id: builddeploywebapp
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_KIND_WAVE_0E91BF90F }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "/client"
api_location: "/api"
output_location: "build"
env:
KEY_VAULT_URL: ${{ secrets.KEY_VAULT_URL }}
CONFIG_API_TOKEN: ${{ secrets.CONFIG_API_TOKEN }}
REACT_APP_CONFIG_API_TOKEN: ${{ secrets.CONFIG_API_TOKEN }}
REACT_APP_CONFIG_API_URL: "api/config"
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_KIND_WAVE_0E91BF90F }}
action: "close"
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.