Skip to content

Commit b509d96

Browse files
committed
docs: add guidance on connecting to a remote API host
1 parent 19c619b commit b509d96

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

docs/www/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Start the development server - this has built-in hot reload so you can preview c
1818

1919
```bash
2020
$ cd docs/www
21+
# If needed, run npm install to install dependencies.
22+
$ npm install
2123
$ npm start
2224
```
2325

docs/www/docs/cli/swa-start.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Here is a list of the default ports used by some popular dev servers:
5151
| [Next.js](https://nextjs.org/) | 3000 | `swa start http://localhost:3000` |
5252
| [React (Create React App)](https://reactjs.org/docs/create-a-new-react-app.html) | 3000 | `swa start http://localhost:3000` |
5353
| [Svelte (sirv-cli)](https://github.com/lukeed/sirv/tree/master/packages/sirv-cli/) | 5000 | `swa start http://localhost:5000` |
54-
| [Vue](https://github.com/vuejs/create-vue) | 3000 | `swa start http://localhost:3000` |
54+
| [Vue](https://github.com/vuejs/create-vue) | 3000 | `swa start http://localhost:3000` |
5555

5656
Instead of starting a dev server separately, you can provide the startup command to the CLI.
5757

@@ -75,7 +75,7 @@ Then access the application with the emulated services from `http://localhost:42
7575

7676
If your project includes API functions, the CLI will check if the Azure Functions Core Tools are installed and available. If not, the CLI will download and install the right version of the Azure Functions Core Tools.
7777

78-
#### Start the API server automatically
78+
#### Start the local API server automatically
7979

8080
Run the CLI and provide the folder that contains the API backend (a valid Azure Functions App project):
8181

@@ -87,7 +87,7 @@ swa start ./my-dist --api-location ./api
8787
swa start http://localhost:3000 --api-location ./api
8888
```
8989

90-
#### Start API server manually
90+
#### Start local API server manually
9191

9292
When developing your backend locally, sometimes it's useful to run Azure Functions Core Tools separately to serve your API. This allows you to use built-in features like debugging and rich editor support.
9393

@@ -100,6 +100,16 @@ To use the CLI with your local API backend dev server, follow these two steps:
100100
swa start ./my-dist --api-location http://localhost:7071
101101
```
102102

103+
#### Connect to a remote API server
104+
105+
SWA CLI supports connecting to APIs hosted remotely, using services such as Azure and AWS. You can also connect to APIs hosted in a debug session in a GitHub Codespace.
106+
107+
For remotely hosted APIs it is necesary to specify both the `--api-location` and `--api-devserver-url` options.
108+
109+
```bash
110+
swa start http://localhost:3000 --api-location remote --api-devserver-url https://my-api-host.example.com
111+
```
112+
103113
## Options
104114

105115
Here are the options you can use with `swa start`:
@@ -108,7 +118,7 @@ Here are the options you can use with `swa start`:
108118
- `-i, --api-location <path>`: the folder containing the source code of the API application
109119
- `-O, --output-location <path>`: the folder containing the built source of the front-end application. The path is relative to `--app-location` (default: ".")
110120
- `-D, --app-devserver-url <url>`: connect to the app dev server at this URL instead of using output location
111-
- `-is, --api-devserver-url <url>`: connect to the api server at this URL instead of using output location
121+
- `-is, --api-devserver-url <url>`: connect to the api server at this URL instead of using output location. Set `--api-location` to `remote` if using this option.
112122
- `-j, --api-port <apiPort>`: the API server port passed to `func start` (default: 7071)
113123
- `-q, --host <host>`: the host address to use for the CLI dev server (default: "localhost")
114124
- `-p, --port <port>`: the port value to use for the CLI dev server (default: 4280)
@@ -160,6 +170,12 @@ Connect both front-end and the API to running development server
160170
swa start http://localhost:3000 --api-location http://localhost:7071
161171
```
162172

173+
Connect to a local front-end development server and a remote API server
174+
175+
```bash
176+
swa start http://localhost:3000 --api-location remote --api-devserver-url https://remote-api-host.example.com
177+
```
178+
163179
## See Also
164180

165181
- [swa](./swa)

0 commit comments

Comments
 (0)