netlify / cli

Netlify Command Line Interface
http://cli.netlify.com
MIT License
1.57k stars 351 forks source link

Browser-sync http2 server returns "Could not proxy request." #4611

Open hylmar opened 2 years ago

hylmar commented 2 years ago

Describe the bug

My local environment was running smoothly with netlify dev booting my custom framework, which simply started an http server using browser-sync. However, I wanted my local dev environment to use http2, so I updated my setup accordingly. Now when I start my server through netlify dev, my custom framework is serving everything well with http2 at port 8000, but the netlify layer at port 9000 returns "Could not proxy request."

I've tried debugging netlify-cli, but no luck so far. Does anyone have a clue what could be the issue?

Steps to reproduce

  1. run git clone git@github.com:hylmar/http2-test.git;
  2. run yarn to install;
  3. run yarn dev to start;
  4. browse https://localhost:8000/; this works;
  5. browse https://localhost:9000/; this says Could not proxy request..

Configuration

[build]
  functions = "build/functions"
  base = ""
  publish = "build"
  command = "npm run deploy"

[dev]
  framework = "#custom"
  command = "koios dev"
  targetPort = 8000
  port = 9000
  publish = "build"
  autoLaunch = false

[dev.https]
  certFile = "cert/localhost-cert.pem"
  keyFile = "cert/localhost-privkey.pem"

Environment

  System:
    OS: macOS 11.6
    CPU: (8) x64 Apple M1
    Memory: 172.72 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.14.0/bin/yarn
    npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
  npmGlobalPackages:
    netlify-cli: 10.3.1
dsolanorush commented 1 year ago

@hylmar - I'm having this same issue. Did you find a solution?

tinfoil-knight commented 1 year ago

Hey @dsolanorush, I tried to debug this issue with the given repo but wasn't able to due to unrelated errors in the repository. If you've a public repo where I could reproduce this issue, I can try again.

dsolanorush commented 1 year ago

@tinfoil-knight - the root of the issue for me was two-fold. In nuxt.config.js server config I had:

  1. host set to 0.0.0.0
  2. https cert applied

I completely removed the custom server config and let Nuxt use defaults, then applied my existing cert to the Netlify dev server TOML config. This allowed proxying to work as expected.