Azure / Azure/static-web-apps-cli
`swa` does not recognize that the api is started when `localhost` resolves to `::1`
- Dominant language
- TypeScript
- Stars
- 668
- Forks
- 156
- PR merge metrics
- No merged PRs in 30d
Description
**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
- [x] Yes, I am accessing the CLI from port `:4280`
**Describe the bug**
When starting my static web app, which has both static files and functions, `swa` get's stuck waiting for the api on `http://localhost:7071` even when the azure function core tools have started the api. It seems this happens because `localhost` resolves to `::1` (The IPv6 loopback address) on my system, while the api is started on `127.0.0.1` (IPv4 loopback address).
My **workaround** is to specify the `host` property in `swa-cli.config.json` or the `--host` flag to be `127.0.0.1`.
**To Reproduce**
Steps to reproduce the behavior:
1. Be on a system where `localhost` resolves to `::1`. The most consistent test for this in this case is to see which IP address `wait-on` resolves (`swa` uses `wait-on`) by running `npx wait-on -v tcp:localhost:7071`
2. Have a SWA app with both static files and functions. Configure `swa-cli.config.json` with `outputLocation` and `apiLocation` as needed, but without `host` or similar.
3. Execute command `swa start`
4. After a while, you will get the message
```
[swa] ✖ Waiting for http://localhost:7071 to be ready
[swa] ✖ Could not connect to "http://localhost:7071". Is the server up and running?
```
**Expected behavior**
`swa` should successfully start up. In particular the message below is expected.
```
[swa] ✔ Connected to http://127.0.0.1:7071 successfully
```
**Desktop (please complete the following information):**
- OS: Fedora Linux 37 Workstation Edition
- `uname -a`: `Linux xps13 6.1.5-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jan 12 15:52:00 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux`
Contributor guide
Assessment
This issue has not been assessed yet.