Skip to content

Commit

Permalink
serve https if there is ca.crt and ca.key
Browse files Browse the repository at this point in the history
  • Loading branch information
NaitLee committed Mar 15, 2024
1 parent e241e08 commit 711bdb3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
_fresh/

*.kate-swp
ca.crt
ca.key
16 changes: 15 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,18 @@ import "$std/dotenv/load.ts";
import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";

await start(manifest);
const cert_file = 'ca.crt';
const key_file = 'ca.key';

const cert = await Deno.readTextFile(cert_file).catch(() => '');
const key = await Deno.readTextFile(key_file).catch(() => '');

if (cert !== '' && key !== '')
await start(manifest, {
server: {
cert: cert,
key: key
}
});
else
await start(manifest);

0 comments on commit 711bdb3

Please sign in to comment.