swa start doesn't run both api and static site together
See original GitHub issueDescribe the bug I cannot start the static page and api at the same time using one command.
To Reproduce
- Follow the tutorial here https://learn.microsoft.com/en-us/azure/static-web-apps/getting-started?tabs=vanilla-javascript
- Get to the running locally step https://learn.microsoft.com/en-us/azure/static-web-apps/add-api?tabs=vanilla-javascript#start-the-cli
- run the command
swa start src --api-location api
Expected behaviour I expect to be able to browse to http://localhost:4280 and make a GET api call to http://localhost:7071/api/message but can only access the api, the site at 4280 is not running.
If I run the command swa start src
then I get the http://localhost:4280 site running, but obviously not the API
Output (verbose)
log from running swa start src --api-location api --verbose=silly
Welcome to Azure Static Web Apps CLI (1.0.3)
Getting config file options from swa-cli.config.json...
Config file does not exist at C:\<redacted>\spa-vanilla\swa-cli.config.json
***********************************************************************
* WARNING: This emulator may not match the cloud environment exactly. *
* Always deploy and test your app in Azure. *
***********************************************************************
Checking if localhost:4280 is accepting TCP connections...
Port 4280 is available. Use it.
Resolved port number: 4280
Resolving outputLocation=src full path...
Resolved outputLocation:
C:\<redacted>\spa-vanilla\src
Trying to read workflow config with values:
- appLocation: C:\<redacted>\spa-vanilla
- outputLocation: C:\<redacted>\spa-vanilla\src
- apiLocation: C:\<redacted>\spa-vanilla\api
Found a SWA workflow file: C:\<redacted>\spa-vanilla\.github\workflows\azure-static-web-apps-thankful-island-0c2e35803.yml
- app_build_command: <undefined>
- api_build_command: <undefined>
- app_location: /src
- output_location: /src
- api_location: api
Validating user workflow config (BEFORE):
- appLocation: C:\<redacted>\spa-vanilla
- outputLocation: C:\<redacted>\spa-vanilla\src
- apiLocation: C:\<redacted>\spa-vanilla\api
Validating user workflow config (AFTER):
- appLocation: C:\<redacted>\spa-vanilla
- apiLocation: C:\<redacted>\spa-vanilla\api
- outputLocation: C:\<redacted>\spa-vanilla\src
Workflow configuration:
- config:
- appBuildCommand: <undefined>
- apiBuildCommand: <undefined>
- appLocation: C:\<redacted>\spa-vanilla
- apiLocation: C:\<redacted>\spa-vanilla\api
- outputLocation: C:\<redacted>\spa-vanilla\src
- files:
- 0: C:\<redacted>\spa-vanilla\.github\workflows\azure-static-web-apps-thankful-island-0c2e35803.yml
User workflow config:
- appBuildCommand: <undefined>
- apiBuildCommand: <undefined>
- appLocation: C:\<redacted>\spa-vanilla
- apiLocation: C:\<redacted>\spa-vanilla\api
- outputLocation: C:\<redacted>\spa-vanilla\src
- files:
- 0: C:\<redacted>\spa-vanilla\.github\workflows\azure-static-web-apps-thankful-island-0c2e35803.yml
Starting the SWA emulator with the following configuration:
- ssl:
- 0: false
- 1: <undefined>
- 2: <undefined>
- env:
- SWA_RUNTIME_CONFIG_LOCATION: C:\<redacted>\spa-vanilla
- SWA_RUNTIME_WORKFLOW_LOCATION: C:\<redacted>\spa-vanilla\.github\workflows\azure-static-web-apps-thankful-island-0c2e35803.yml
- SWA_CLI_DEBUG: silly
- SWA_CLI_API_PORT: 7071
- SWA_CLI_APP_LOCATION: C:\<redacted>\spa-vanilla
- SWA_CLI_OUTPUT_LOCATION: C:\<redacted>\spa-vanilla\src
- SWA_CLI_API_LOCATION: C:\<redacted>\spa-vanilla\api
- SWA_CLI_HOST: localhost
- SWA_CLI_PORT: 4280
- SWA_CLI_APP_SSL: false
- SWA_CLI_APP_SSL_CERT: <undefined>
- SWA_CLI_APP_SSL_KEY: <undefined>
- SWA_CLI_STARTUP_COMMAND: <undefined>
- SWA_CLI_VERSION: 1.0.3
- SWA_CLI_SERVER_TIMEOUT: 60
- SWA_CLI_OPEN_BROWSER: false
- commands:
- swa: node "C:\Users\peter\AppData\Roaming\npm\node_modules\@azure\static-web-apps-cli\dist\msha\server.js"
- api: cd "C:\<redacted>\spa-vanilla\api" && C:\Users\peter\.swa\core-tools\v4\func start --cors "*" --port 7071
- run: <undefined>
[api]
Azure Functions Core Tools
[api] Core Tools Version: 4.0.4865 Commit hash: N/A (32-bit)
[api] Function Runtime Version: 4.12.2.19454
[api]
[swa]
[swa] Using workflow file:
[swa] C:\<redacted>\spa-vanilla\.github\workflows\azure-static-web-apps-thankful-island-0c2e35803.yml
[api] [2022-11-08T14:32:37.538Z] File 'C:\Program Files (x86)\dotnet\dotnet.exe' is not found, 'dotnet' invocation will rely on the PATH environment variable.
[swa] No staticwebapp.config.json found in current project
[swa] Validating dev server config:
[swa] - url: http://localhost:7071
[swa] - timeout: 60
[swa] Checking if localhost:7071 is accepting TCP connections...
[swa] - Waiting for http://localhost:7071 to be ready
[api] [2022-11-08T14:32:37.806Z] File 'C:\Program Files (x86)\dotnet\dotnet.exe' is not found, 'dotnet' invocation will rely on the PATH environment variable.
[api]
[api] Functions:
[api]
[api] message: http://localhost:7071/api/message
[api]
[api] For detailed output, run func with --verbose flag.
[api] [2022-11-08T14:32:38.320Z] Worker process started and initialized.
log from running swa start src --verbose=silly
Welcome to Azure Static Web Apps CLI (1.0.3)
Getting config file options from swa-cli.config.json...
Config file does not exist at C:\<redacted>\spa-vanilla\swa-cli.config.json
***********************************************************************
* WARNING: This emulator may not match the cloud environment exactly. *
* Always deploy and test your app in Azure. *
***********************************************************************
Checking if localhost:4280 is accepting TCP connections...
Port 4280 is available. Use it.
Resolved port number: 4280
Resolving outputLocation=src full path...
Resolved outputLocation:
C:\<redacted>\spa-vanilla\src
Trying to read workflow config with values:
- appLocation: C:\<redacted>\spa-vanilla
- outputLocation: C:\<redacted>\spa-vanilla\src
- apiLocation: <undefined>
Found a SWA workflow file: C:\<redacted>\spa-vanilla\.github\workflows\azure-static-web-apps-thankful-island-0c2e35803.yml
- app_build_command: <undefined>
- api_build_command: <undefined>
- app_location: /src
- output_location: /src
- api_location: api
Validating user workflow config (BEFORE):
- appLocation: C:\<redacted>\spa-vanilla
- outputLocation: C:\<redacted>\spa-vanilla\src
- apiLocation: <undefined>
Validating user workflow config (AFTER):
- appLocation: C:\<redacted>\spa-vanilla
- apiLocation: <undefined>
- outputLocation: C:\<redacted>\spa-vanilla\src
Workflow configuration:
- config:
- appBuildCommand: <undefined>
- apiBuildCommand: <undefined>
- appLocation: C:\<redacted>\spa-vanilla
- apiLocation: <undefined>
- outputLocation: C:\<redacted>\spa-vanilla\src
- files:
- 0: C:\<redacted>\spa-vanilla\.github\workflows\azure-static-web-apps-thankful-island-0c2e35803.yml
User workflow config:
- appBuildCommand: <undefined>
- apiBuildCommand: <undefined>
- appLocation: C:\<redacted>\spa-vanilla
- apiLocation: <undefined>
- outputLocation: C:\<redacted>\spa-vanilla\src
- files:
- 0: C:\<redacted>\spa-vanilla\.github\workflows\azure-static-web-apps-thankful-island-0c2e35803.yml
Starting the SWA emulator with the following configuration:
- ssl:
- 0: false
- 1: <undefined>
- 2: <undefined>
- env:
- SWA_RUNTIME_CONFIG_LOCATION: C:\<redacted>\spa-vanilla
- SWA_RUNTIME_WORKFLOW_LOCATION: C:\<redacted>\spa-vanilla\.github\workflows\azure-static-web-apps-thankful-island-0c2e35803.yml
- SWA_CLI_DEBUG: silly
- SWA_CLI_API_PORT: 7071
- SWA_CLI_APP_LOCATION: C:\<redacted>\spa-vanilla
- SWA_CLI_OUTPUT_LOCATION: C:\<redacted>\spa-vanilla\src
- SWA_CLI_API_LOCATION: <undefined>
- SWA_CLI_HOST: localhost
- SWA_CLI_PORT: 4280
- SWA_CLI_APP_SSL: false
- SWA_CLI_APP_SSL_CERT: <undefined>
- SWA_CLI_APP_SSL_KEY: <undefined>
- SWA_CLI_STARTUP_COMMAND: <undefined>
- SWA_CLI_VERSION: 1.0.3
- SWA_CLI_SERVER_TIMEOUT: 60
- SWA_CLI_OPEN_BROWSER: false
- commands:
- swa: node "C:\Users\peter\AppData\Roaming\npm\node_modules\@azure\static-web-apps-cli\dist\msha\server.js"
- api: <undefined>
- run: <undefined>
[swa]
[swa] Using workflow file:
[swa] C:\<redacted>\spa-vanilla\.github\workflows\azure-static-web-apps-thankful-island-0c2e35803.yml
[swa] No staticwebapp.config.json found in current project
[swa]
[swa] Serving static content:
[swa] C:\<redacted>\spa-vanilla\src
[swa]
[swa] Azure Static Web Apps emulator started at http://localhost:4280. Press CTRL+C to exit.
[swa]
[swa]
Desktop (please complete the following information):
- OS: Windows: 10
- @azure/static-web-apps-cli@1.0.3
- azure-functions-core-tools@4.0.4865
Issue Analytics
- State:
- Created 10 months ago
- Reactions:1
- Comments:13 (5 by maintainers)
Top Results From Across the Web
swa start | Static Web Apps CLI
This command is used to start the Azure Static Web Apps emulator from a ... In a separate terminal, run the SWA CLI...
Read more >Set up local development for Azure Static Web Apps
Create a static web app (React and API) and locally develop using the SWA CLI. Run the same code locally and remotely to...
Read more >Azure Static Web Apps CLI work with my blazor client ...
When I run swa --version. I get back the result. 1.0.3. In the solution I have both the Api and the Client app...
Read more >Static Web App CLI
4. In the last terminal window, we can run the SWA CLI itself to join these two together. Go to the root folder...
Read more >Setting up Azure Static Web Apps local development ...
An Azure Static Web Apps site consists of several services that work together: static web, API functions, authentication and authorization, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have downgraded node to 16.18.1 and it works now.
I was previously running node 18.12.1
Hi @peterfearn, We are investigating this and will get back to you with further questions for clarification!