how to use http2 on dev for the 'create-react-app' environment. I can't see anything about that in the README or quick googling. please help me out
CodePudding user response:
Making your React App http2, is nothing to do with react actually. It's all about how the build resources (js, html, css files) are served from (communication between server to browser).
nginx
If you serve the frontend from nginx then you can enable http2 in nginx.conf file.
https://ubiq.co/tech-blog/how-to-enable-http2-in-nginx/
envoy
If you use envoyproxy in the edge, then enable it from it's configuration. How to use TLS & HTTP/2 with Envoy Proxy
Node.js
If you use a simple node.js server then enable it there. https://nodejs.org/api/http2.html https://nodejs.org/api/http2.html#server-side-example
CodePudding user response:
You don't and can't change this from your react app, or any frontend app in general.
The server that your frontend app is served from, or sends requests to, would be the place to configure the version of http used. And it'll only work if the frontend app is being run from a browser that supports http2, otherwise the requests won't get upgraded to http2 and version 1 will be used instead.