lwsjs / local-web-server

A lean, modular web server for rapid full-stack development.
MIT License
1.2k stars 85 forks source link

Rewrite not working in 2.5.2 (Protocol missing from request) #95

Closed tclift closed 6 years ago

tclift commented 6 years ago

shell 1:

$ npx ws --stack rewrite --rewrite '* -> http://localhost:8000/foo'

shell 2:

$ wget http://localhost:8000

shell 1 output:

Serving at http://myhost.local:8000, http://127.0.0.1:8000
09:08:45: Middleware error
Error: Protocol missing from request: {
  "headers": {
    "user-agent": "Wget/1.19.4 (darwin17.3.0)",
    "accept": "*/*",
    "accept-encoding": "identity",
    "host": null,
    "connection": "Keep-Alive"
  },
  "protocol": null,
  "slashes": null,
  "auth": null,
  "host": null,
  "port": null,
  "hostname": null,
  "hash": null,
  "search": null,
  "query": null,
  "pathname": "/",
  "path": "/",
  "href": "/",
  "method": "GET",
  "rejectUnauthorized": false
}
    at request (/lws-repro/node_modules/req-then/index.js:64:27)
    at Promise (/lws-repro/node_modules/lws-rewrite/index.js:116:32)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

package.json:

{
  "dependencies": {
    "local-web-server": "2.5.2"
  }
}

npm version:

npm version
{ npm: '6.0.0',
  ares: '1.10.1-DEV',
  cldr: '31.0.1',
  http_parser: '2.7.0',
  icu: '59.1',
  modules: '57',
  nghttp2: '1.25.0',
  node: '8.9.4',
  openssl: '1.0.2n',
  tz: '2017b',
  unicode: '9.0',
  uv: '1.15.0',
  v8: '6.1.534.50',
  zlib: '1.2.11' }
aheld commented 6 years ago

I am seeing the same error. rolling back to 2.5.0 works

75lb commented 6 years ago

Hi, sorry for the delay.. I have reproduced this and will get it fixed ASAP.

75lb commented 6 years ago

Fixed and released in lws-rewrite v0.4.1, please reinstall local-web-server to pick up the change.

I traced the issue to an update in path-to-regexp which "removed the asterisk functionality". At some point in the future I will upgrade the path-to-regexp dependency and advise people to use the new (.*) syntax instead.