http-party / http-server

a simple zero-configuration command-line http server
MIT License
13.58k stars 1.49k forks source link

{"message":"You are not authorized"} in GitHub Codespace #864

Closed davetapley closed 1 year ago

davetapley commented 1 year ago

Environment Versions

  1. OS Type
  2. Node version: v18.17.1
  3. http-server version: v14.1.1

Steps to reproduce

  1. Start a GitHub Codespace
  2. npx http-server
  3. Codespace will auto-forward port 8080

Expected result

Navigate to http://localhost:8080/ in browser and see files

Actual result

Navigate to http://localhost:8080/ and see:

{"message":"You are not authorized"}

...

Other information

I'm not 100% sure if this is http-server or Codespace, but I figured I'd open in case others see / can reproduce.

If I curl localhost:8080 in the Codespace I can see the listing just fine, and https://ngrok.com/ works too.

See also: https://github.com/orgs/community/discussions/64558

zbynek commented 1 year ago

For me it works with empty codespace (which by default has Node 20 -- not sure if that could be different to Node 18).

Navigate to http://localhost:8080/ in browser and see files

Note that the URL in browser address bar needs to be something like https://foo-bar-baz-8080.app.github.dev/ -- if you actually try to open localhost in your browser it won't work.

Also: when you're running http-server in terminal, you should see a log of all the URLs that were served -- does it produce any output when you try to open the codespace URL in a browser?

davetapley commented 1 year ago

@zbynek well that's embarrassing, I also cannot repro in an empty Codespace, because:

I just realized there's already a different web-server running on 8080 on my other Codespace, but weirdly I didn't get a Error: listen EADDRINUSE: address already in use 0.0.0.0:8080 when trying to start http-server 🤔

The other server is defined via dockerComposeFile in the devcontainer.json. I'll do some more digging, but probably safe to say not a http-server issue...