createServer

external fun <Request : IncomingMessage, Response : ServerResponse<*>> createServer(requestListener: RequestListener<Request, Response> = definedExternally): Server<Request, Response>(source)
// curl -k https://localhost:8000/
const https = require('node:https');
const fs = require('node:fs');

const options = {
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
};

https.createServer(options, (req, res) => {
res.writeHead(200);
res.end('hello world\n');
}).listen(8000);

Or

const https = require('node:https');
const fs = require('node:fs');

const options = {
pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
passphrase: 'sample',
};

https.createServer(options, (req, res) => {
res.writeHead(200);
res.end('hello world\n');
}).listen(8000);

Since

v0.3.4

Parameters

options

Accepts options from createServer, createSecureContext and createServer.

requestListener

A listener to be added to the 'request' event.