Documentation Index
Fetch the complete documentation index at: https://bun.zhcndoc.com/llms.txt
Use this file to discover all available pages before exploring further.
设置 tls 键以配置 TLS。key 和 cert 都是必需的。key 应该是你的私钥内容;cert 应该是你颁发的证书内容。使用 Bun.file() 读取内容。
server.tsconst server = Bun.serve({
fetch: request => new Response("Welcome to Bun!"),
tls: {
cert: Bun.file("cert.pem"),
key: Bun.file("key.pem"),
},
});
默认情况下,Bun 信任 Mozilla 精选的知名根证书列表。要覆盖此列表,可以传递一个证书数组作为 ca。
server.tsconst server = Bun.serve({
fetch: request => new Response("Welcome to Bun!"),
tls: {
cert: Bun.file("cert.pem"),
key: Bun.file("key.pem"),
ca: [Bun.file("ca1.pem"), Bun.file("ca2.pem")],
},
});