static-web-apps-cli: [start] Start command does not connect to web or api server on Node 18

Before filing this issue, please ensure you’re using the latest CLI by running swa --version and comparing to the latest version on npm.

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, I am accessing the CLI from port :4280

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

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

Describe the bug On Node 18, npm start never connects to a web or api server, it’s stuck until timeout. On Node 16, no issue.

This is related to this issue https://github.com/jeffbski/wait-on/issues/137 of the wait-on package.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 1
  • Comments: 36 (12 by maintainers)

Most upvoted comments

It works for me as well, the main problem is that the performance of the site is terrible when compared not running through swa cli. Pages take long time to load and resources (for example > 1s to load a font)

One issue is that once the --api-devserver-url option is set, the Function API emulator doesn’t start automatically anymore and need to be run manually.

You are right, but that’s why you include the --host in combination with the --api-location option (and not the --api-devserver-url option), in my example I omitted the api-location option, but it should look something like:

swa start --host=127.0.0.1 --app-devserver-url=http://127.0.0.1:<DEVSERVER-PORT> --run "<RUN COMMAND>" --api-location ./api --port <SWA-PORT> --api-port <API-PORT>

This is so painful from user perspective, may be we should try giving these params internally while starting the swa if the node version is 18.

One issue is that once the --api-devserver-url option is set, the Function API emulator doesn’t start automatically anymore and need to be run manually.

You are right, but that’s why you include the --host in combination with the --api-location option (and not the --api-devserver-url option), in my example I omitted the api-location option, but it should look something like:

swa start --host=127.0.0.1 --app-devserver-url=http://127.0.0.1:<DEVSERVER-PORT> --run "<RUN COMMAND>" --api-location ./api --port <SWA-PORT> --api-port <API-PORT>

Hi @cjk7989 thanks for this - yes this runs the Blazor app but on port 5296 - I’ll look to change that to 8000 and get back to you

That’s ok. Or you can add a parameter of swa-cli: “–appDevserverUrl http://localhost:5296” or add this to swa-cli.config.json generated by “swa init”.

YES that was it! Huge apologies, thank you!! Oh that’s really obvious in retrospect.

Ports changed from 5296 -> 8000 in launchSettings.json.

…the next issue being that http://localhost:4280/data-api/graphql/ is returning “Sorry, there’s nothing at this address.” but that’s a separate issue. OK thanks for that guidance.

Hi @cjk7989. Thanks for your response. Looks like the issue fixed itself when I upgraded my node version to latest 🙂.

It works for me as well, the main problem is that the performance of the site is terrible when compared not running through swa cli. Pages take long time to load and resources (for example > 1s to load a font)

It’s getting quite tedious waiting for a fix, tbh.

We are happy to inform you that a new release has been published that fixed the issue. Please update swa-cli to v1.1.4 and let us know if you encounter any issues. Thanks for your feedback and support.

I also still have this issue with Node 18. When I start my dev server manually before executing swa start then it works perfectly, but if I do swa start first and then start my dev server, swa never connects.

Another workaround to get people going with node 18.

Using swa 1.1.1 and Node 18.12.1 i was able to get everything to work as expected with

swa start --host=127.0.0.1 --port=3010 --app-devserver-url=http://127.0.0.1:3000

My react apps runs on 3000 (Vite React) And my public facing endpoint (swa) i now accessible on 3010