How to use the Server function from https

Find comprehensive JavaScript https.Server code examples handpicked from public code repositorys.

11
12
13
14
15
16
17
18
19
20
21
const options = {
  key: fixtures.readKey('agent1-key.pem'),
  cert: fixtures.readKey('agent1-cert.pem')
};


const server = https.Server(options, common.mustCall((req, res) => {
  res.writeHead(200);
  res.end('Hello, World!');
}));

fork icon0
star icon0
watch icon0

12
13
14
15
16
17
18
19
20
21
22
  cert: fixtures.readKey('agent1-cert.pem'),
  ca: fixtures.readKey('ca1-cert.pem'),
  minVersion: 'TLSv1.1',
};


const server = https.Server(options, (req, res) => {
  res.writeHead(200);
  res.end('hello world\n');
});

fork icon0
star icon0
watch icon0