From 008b484e6f50b847790d1c85a82fec98973cbab0 Mon Sep 17 00:00:00 2001 From: Daniel Watford Date: Mon, 3 Oct 2022 13:55:53 +0100 Subject: [PATCH] docs: add guidance on connecting to a remote API host --- docs/www/README.md | 2 ++ docs/www/docs/cli/swa-start.md | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/www/README.md b/docs/www/README.md index 2bb1ca95..329e1926 100644 --- a/docs/www/README.md +++ b/docs/www/README.md @@ -18,6 +18,8 @@ Start the development server - this has built-in hot reload so you can preview c ```bash $ cd docs/www +# If needed, run npm install to install dependencies. +$ npm install $ npm start ``` diff --git a/docs/www/docs/cli/swa-start.md b/docs/www/docs/cli/swa-start.md index 74cff95c..55e6999e 100644 --- a/docs/www/docs/cli/swa-start.md +++ b/docs/www/docs/cli/swa-start.md @@ -51,7 +51,7 @@ Here is a list of the default ports used by some popular dev servers: | [Next.js](https://nextjs.org/) | 3000 | `swa start http://localhost:3000` | | [React (Create React App)](https://reactjs.org/docs/create-a-new-react-app.html) | 3000 | `swa start http://localhost:3000` | | [Svelte (sirv-cli)](https://github.com/lukeed/sirv/tree/master/packages/sirv-cli/) | 5000 | `swa start http://localhost:5000` | -| [Vue](https://github.com/vuejs/create-vue) | 3000 | `swa start http://localhost:3000` | +| [Vue](https://github.com/vuejs/create-vue) | 3000 | `swa start http://localhost:3000` | Instead of starting a dev server separately, you can provide the startup command to the CLI. @@ -75,7 +75,7 @@ Then access the application with the emulated services from `http://localhost:42 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. -#### Start the API server automatically +#### Start the local API server automatically Run the CLI and provide the folder that contains the API backend (a valid Azure Functions App project): @@ -87,7 +87,7 @@ swa start ./my-dist --api-location ./api swa start http://localhost:3000 --api-location ./api ``` -#### Start API server manually +#### Start local API server manually 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. @@ -100,6 +100,14 @@ To use the CLI with your local API backend dev server, follow these two steps: swa start ./my-dist --api-location http://localhost:7071 ``` +#### Connect to a remote API server + +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. + +```bash +swa start http://localhost:3000 --api-location https://my-api-host.example.com +``` + ## Options Here are the options you can use with `swa start`: @@ -160,6 +168,12 @@ Connect both front-end and the API to running development server swa start http://localhost:3000 --api-location http://localhost:7071 ``` +Connect to a local front-end development server and a remote API server + +```bash +swa start http://localhost:3000 --api-location https://remote-api-host.example.com +``` + ## See Also - [swa](./swa)