Azure / static-web-apps-cli

Azure Static Web Apps CLI ✨
https://aka.ms/swa/cli-local-development
MIT License
600 stars 119 forks source link

Could not connect to "http://localhost:8000/" even when the app is running #297

Closed simonaco closed 3 years ago

simonaco commented 3 years ago

Describe the bug Swa cli fails to start with error message [swa] Could not connect to "http://localhost:8000/". Is the server up and running? after successful start of gatsby dev server

To Reproduce Steps to reproduce the behavior:

  1. Go to terminal
  2. Type in command swa start http://localhost:8000/ --api http://localhost:7071 --run "npm start"
  3. See error

Expected behavior Expectation is that swa cli detects that gatsby has started

Screenshots Screenshot 2021-09-19 at 12 19 17

manekinekko commented 3 years ago

Hey @simonaco thank you for reporting this issue. The good news is that we've already fixed it in https://github.com/Azure/static-web-apps-cli/pull/281 (issue https://github.com/Azure/static-web-apps-cli/issues/275). However, we haven't published a release to npm yet. cc @anthonychu.

Just as an FYI, here are the steps I followed (using v 0.7.2 - currently in main branch):

  1. install Gatsby: npm install -g gatsby-cli
  2. create a new blog: gatsby new blog https://github.com/gatsbyjs/gatsby-starter-blog
  3. cd blog
  4. swa start http://localhost:8000 --run "npm start" (I am not using SWA API)
  5. access blog at http://localhost:4280
  6. access GraphQL console at: http://localhost:4280/___graphql

As you can see from my screenshots image

image

Reshmi-Sriram commented 3 years ago

Hey @simonaco, We have an upcoming release this week and you should see it in the latest npm package soon! 😄

manekinekko commented 3 years ago

This is awesome! Thank you @Reshmi-Sriram 👍

sgollapudi77 commented 3 years ago

Hii @simonaco we've done a new release today and previous changes have been included in this, please check once.

simonaco commented 3 years ago

thank you @Reshmi-Sriram @sgollapudi77 . I just tested with a simple Gatsby app and one API endpoint and I'm still seeing issues, please check this screen recording swa-cli doesn't start

sample repo is here https://github.com/simonaco/swa-cli-297

simonaco commented 3 years ago

Thank you @manekinekko for debugging with me. It seems like the issue was related to how I was starting the CLI. When using this command, swa start http://localhost:8000/ --api http://localhost:7071 --run "npm start" I need to have the functions server started.

Alternatively I can use this command to instruct the CLI to start the functions dev server: swa start http://localhost:8000/ --api api --run "npm start"