Azure / Azure/static-web-apps-cli

Default proxy setting is not working for SWA CLI and still download metadata for StaticSitesClient from internet after downloaded & manually configured StaticSitesClient.json

Open
#911 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
668
Forks
156
PR merge metrics
No merged PRs in 30d

Description

swa --version
2.0.2

**Are you accessing the CLI from the default port `:4280` ?**

- [ ] No, I am using a different port number (`--port`) and accessing the CLI from that port
- [Yes ] Yes, I am accessing the CLI from port `:4280`

> Make sure you are accessing the URL printed in the console when running `swa start`!
```
swa start

Welcome to Azure Static Web Apps CLI (2.0.2)

***********************************************************************
* WARNING: This emulator may not match the cloud environment exactly. *
* Always deploy and test your app in Azure. *
***********************************************************************

Serving static content:
/home/aaaa

Azure Static Web Apps emulator started at http://localhost:4280. Press CTRL+C to exit.
```

**ℹ️ NOTE: Make sure to enable debug logs when running any `swa` commands using `--verbose=silly`**
Yes

**Describe the bug**
We are trying to deploy static web app from azure vm acting as azure devops agent. Thus, from azure pipeline we are running `swa deploy` command. Our vm is behind proxy,

hence when running swa cli command its not able to download StaticSitesClient directly. As per https://azure.github.io/static-web-apps-cli/docs/contribute/Troubleshooting#unable-to-download-staticsitesclient-binary-file-not-found-404---403 we have downloaded manually, kept under user home dir. as per suggested path and along with created .json file

```
pwd
/home/aaaa/.swa/deploy

total 4
drwx------. 2 aaaa domain users 31 Jan 6 11:34 53b7d0e07fe5c34bf68929fab92f87ce910288dc
-rw-------. 1 aaaa domain users 1154 Jan 6 11:59 StaticSitesClient.json

ls -l 53b7d0e07fe5c34bf68929fab92f87ce910288dc/
total 69552
-rwx------. 1 aaaa domain users 71217367 Jan 6 11:34 StaticSitesClient

cat StaticSitesClient.json
{
"metadata": {
"version": "stable",
"buildId": "53b7d0e07fe5c34bf68929fab92f87ce910288dc",
"publishDate": "2024-10-24T20:43:23.5850191Z",
"files": {
"linux-x64": {
"url": "https://swalocaldeployv2-bndtgugjgqc3dhdx.b01.azurefd.net/downloads/53b7d0e07fe5c34bf68929fab92f87ce910288dc/linux/StaticSitesClient",
"sha": "66fca4b42cbc64d451097931ca4ed75649233bd818f97f0c3f6d1d75cff61413"
},
"win-x64": {
"url": "https://swalocaldeployv2-bndtgugjgqc3dhdx.b01.azurefd.net/downloads/53b7d0e07fe5c34bf68929fab92f87ce910288dc/windows/StaticSitesClient.exe",
"sha": "fc949fb19d29cce1e8b74cf1e2c31706426d46b3e03d830d601524cee63faa0b"
},
"osx-x64": {
"url": "https://swalocaldeployv2-bndtgugjgqc3dhdx.b01.azurefd.net/downloads/53b7d0e07fe5c34bf68929fab92f87ce910288dc/macOS/StaticSitesClient",
"sha": "89ec4fe61217325e89ed849a564ffe4cc51b61c325abdca82e8e441a4959ec92"
}
}
},
"binary":"/home/aaaa/.swa/deploy/53b7d0e07fe5c34bf68929fab92f87ce910288dc/StaticSitesClient",
"checksum": "66fca4b42cbc64d451097931ca4ed75649233bd818f97f0c3f6d1d75cff61413"
}
```

However when running swa deploy command its still going to download metadata and failing while deployment
```
2025-01-06T12:14:18.8438630Z Fetching release metadata for version: stable. Please wait...
2025-01-06T12:14:18.8442385Z GET https://aka.ms/swalocaldeploy
2025-01-06T12:14:18.9487549Z Could not find release metadata; returning undefined
2025-01-06T12:14:18.9494834Z ✖
2025-01-06T12:14:18.9499827Z ✖ Deployment Failed :(
2025-01-06T12:14:18.9504798Z ✖ Deployment Failure Reason: Could not load StaticSitesClient metadata from remote. Please check your internet connection.
2025-01-06T12:14:18.9507266Z ✖ For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/azure/static-web-apps/
2025-01-06T12:14:18.9510175Z
```

We have setup HTTP_PROXY & HTTPS_PROXY as well before running SWA cli commands. But somehow it seems SWA commands are not considering these proxy settings.
Because, manually directly from machine when getting from this url using curl command then able to download. ex.
```
curl -x http://10.10.10.10.:443 -L aka.ms/swalocaldeploy
[
{
"version": "latest",
"buildId": "53b7d0e07fe5c34bf68929fab92f87ce910288dc",
"publishDate": "2024-10-24T20:43:23.5850191Z",
"files": {
"linux-x64": {
"url": "https://swalocaldeployv2-bndtgugjgqc3dhdx.b01.azurefd.net/downloads/53b7d0e07fe5c34bf68929fab92f87ce910288dc/linux/StaticSitesClient",
"sha": "66fca4b42cbc64d451097931ca4ed75649233bd818f97f0c3f6d1d75cff61413"
},
"win-x64": {
"url": "https://swalocaldeployv2-bndtgugjgqc3dhdx.b01.azurefd.net/downloads/53b7d0e07fe5c34bf68929fab92f87ce910288dc/windows/StaticSitesClient.exe",
"sha": "fc949fb19d29cce1e8b74cf1e2c31706426d46b3e03d830d601524cee63faa0b"
},
"osx-x64": {
"url": "https://swalocaldeployv2-bndtgugjgqc3dhdx.b01.azurefd.net/downloads/53b7d0e07fe5c34bf68929fab92f87ce910288dc/macOS/StaticSitesClient",
"sha": "89ec4fe61217325e89ed849a564ffe4cc51b61c325abdca82e8e441a4959ec92"
}
}

```

**Expected behavior**

- Option for SWA commands to consider Proxy configurations
- After manually downloaded StaticSitesClient and validated configured checksum, then direct deployment should work

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.