Serve Fresh over HTTPS locally
How can I serve Fresh over HTTPS locally? In node I might generate certs and do
What would the equivalent be for Fresh?
Thanks in advance!
What would the equivalent be for Fresh?
Thanks in advance!
main.ts file to conditionally call serveTls like so
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { ServerContext, start } from "$fresh/server.ts";
import { serveTls } from "https://deno.land/std@0.184.0/http/server.ts";
import manifest from "./fresh.gen.ts";
import twindPlugin from "$fresh/plugins/twind.ts";
import twindConfig from "./twind.config.ts";
const port = parseInt(Deno.env.get("PORT") || "8000", 10);
const opts = { port, plugins: [twindPlugin(twindConfig)] };
if (Deno.env.get("RUN_HTTPS") === "https://localhost:8000") {
const ctx = await ServerContext.fromManifest(manifest, opts);
await serveTls(ctx.handler(), {
port,
certFile: "./local-certs/localhost.crt",
keyFile: "./local-certs/localhost.key",
});
} else {
await start(manifest, opts);
}