Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/http/mod.ts>serveTls

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function serveTls
import { serveTls } from "https://deno.land/std@0.114.0/http/mod.ts";

Serves HTTPS requests with the given handler.

You must specify keyFile and certFile options.

You can specifies addr option, which is the address to listen on, in the form "host:port". The default is "0.0.0.0:8443".

The below example serves with the default port 8443.

import { serveTls } from "https://deno.land/std@0.114.0/http/server.ts";
const certFile = "/path/to/certFile.crt";
const keyFile = "/path/to/keyFile.key";
console.log("server is starting at https://localhost:8443");
serveTls((_req) => new Response("Hello, world"), { certFile, keyFile });

Parameters

handler: Handler

The handler for individual HTTPS requests.

options: ServeTlsInit

The options. See ServeTlsInit documentation for details.

Returns

Promise<void>