json-server icon indicating copy to clipboard operation
json-server copied to clipboard

Http2 support

Open meriturva opened this issue 9 years ago • 2 comments

Any way to support http2 protocol?

Thanks. Diego

meriturva avatar Sep 11 '17 08:09 meriturva

Not possible until these issues are fixed in node: https://stackoverflow.com/questions/50819872/using-nodejs-10-http2-and-express-crashes https://github.com/expressjs/express/issues/3388 https://github.com/nodejs/node/issues/14672

amard33p avatar Jan 22 '20 17:01 amard33p

I have it working with this code:

const jsonServer = require('json-server');`
const server = jsonServer.create();
const spdy = require('spdy');

const port = 8080;
spdy.createServer({
  key: fs.readFileSync(__dirname + '/localhost.key'),
  cert: fs.readFileSync(__dirname + '/localhost.crt')
}, server).listen(port, (error) => {
  if (error) {
    console.error(error);
  } else {
    console.log(`JSON Server is running on port ${port}`);
  }
});

Versions: "json-server": "^0.16.1" "spdy": "^4.0.2"

andriy101 avatar Dec 28 '20 13:12 andriy101