vercel / serve

Static file serving and directory listing
https://npmjs.com/package/serve
MIT License
9.24k stars 684 forks source link

HTTP2 #521

Open FDiskas opened 5 years ago

FDiskas commented 5 years ago

Can we have http2 enabled via argument or by default?

https://github.com/zeit/serve/blob/67f6f613e4b525d9cb7b1a80461895863026d3e6/bin/serve.js#L4

https://nodejs.org/api/http2.html

n8sabes commented 4 years ago

An --http2 option would allow serve to better work with lighthouse and provide scores that are faster/easer to read during development. When you're always seeing sub 100's, you have to go investigate why, and it's just annoying.

I've temporarily moved to local-web-server for my react dev out of irritation in the interim until we can get HTTP/2 supported (or I learn how with serve).

The following configuration with local-web-server in my package scripts produces Lighthouse Scores of 100 across all categories:

ws --directory ./build/ --http2 --compress --spa lighthouse --view --chrome-flags="--ignore-certificate-errors" https://127.0.0.1:8000

weisk commented 4 years ago

@n8sabes wouldnt it be better to leave the "server" stuff to a real production server? Like just reverse proxy and leave all that to nginx, or apache... which are the real battle horses in that area...

by the way that's a nice node server! local-web-server

geoffp commented 4 years ago

My use case would be performance testing during development. I'm trying to show (without too much effort) that HTTP2 without bundling performs comparably to HTTP1 with bundling, but it seems like quite a bit more effort to stand up an Nginx docker image or something.

It would be very helpful to me if serve did this out of the box.

styfle commented 4 years ago

Hi @FDiskas

As @weisk mentioned, the serve cli is not intended to use for production applications.

Instead you can deploy to ZEIT Now by connecting your Git Repository in couple clicks. Then each time you git push it will deploy!

You get HTTP2, TLS 1.3, Brotli compression, and many other features automatically.

Try this: https://zeit.co/import/git

ntucker commented 3 years ago

1) Not everyone is using Now, nor does this make sense for everyone. 2) Even when using a CI system, local development will always be faster and thus allow quicker iteration.

Is open source really only just a marketing platform for you?

FDiskas commented 3 years ago

Http 2 - would be better for development. I know that ssl is a requirement for http2 and probably it is not easy to implement for localhost. Can you imagine how satisfied development would be using http2? :)

abraham commented 3 years ago

Web.dev recently did a series on when and how to use HTTPS locally.

kosiakMD commented 2 years ago

I'm voting for http2 feature to be present here ;)

sanioka commented 1 year ago

Please, add h2 protocol for serve 🙏