-1

I am building a web app that uses a express and node.js in the backend. In my server.js file, I have the following code

const express = require("express");
const app = express();
const server = require("http").Server(app);
const io = require("socket.io")(server);

I recently discovered that there is http2 available, should I change the line 3 to const server = require("http2").Server(app); instead?

If I switch to http2, is there anything else I need to specifically change that wasn't present in http1? And is the way of sending HTTP requests such as get or post any different from http1 to http2?

Chen
  • 860
  • 10
  • 32

1 Answers1

1

HTTP2 is more efficient and loads faster pages-Differences. But I suggest you use https since its more secure and most of the browsers mark non https requests as insecure. similar stack

SHARAD
  • 108
  • 10
  • ok, so I would have `const server = require("http").Server(app);` – Chen Jun 24 '20 at 21:01
  • For development use `http` but for production I recommend using `https`. Also if this reply answers your question than you can mark it as _accepted_ answer. – SHARAD Jun 24 '20 at 21:58