function createServer
Jump to headingcreateServer<Request extends http.IncomingMessage = http.IncomingMessage,Response extends http.ServerResponse = http.ServerResponse,>(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>// curl -k https://localhost:8000/
import https from 'node:https';
import fs from '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
import https from 'node:https';
import fs from '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);
Type Parameters Jump to heading
Jump to headingRequest extends http.IncomingMessage = http.IncomingMessageJump to headingResponse extends http.ServerResponse = http.ServerResponseParameters Jump to heading
optional
Jump to headingrequestListener: http.RequestListener<Request, Response>A listener to be added to the 'request' event.
Return Type Jump to heading
Jump to headingcreateServer<Request extends http.IncomingMessage = http.IncomingMessage,Response extends http.ServerResponse = http.ServerResponse,>(options: ServerOptions<Request, Response>,requestListener?: http.RequestListener<Request, Response>,): Server<Request, Response>Type Parameters Jump to heading
Jump to headingRequest extends http.IncomingMessage = http.IncomingMessageJump to headingResponse extends http.ServerResponse = http.ServerResponseParameters Jump to heading
Jump to headingoptions: ServerOptions<Request, Response>optional
Jump to headingrequestListener: http.RequestListener<Request, Response>