Skip to content

Commit

Permalink
fix(deno-server): explicitly remove cert/key from options if either i…
Browse files Browse the repository at this point in the history
…s not set (#2373)
  • Loading branch information
pi0 committed Jun 27, 2024
1 parent 2dbd4bb commit ccc3003
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/runtime/entries/deno-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,26 @@ if (Deno.env.get("DEBUG")) {
);
}

// https://deno.land/api@v1.34.3?s=Deno.serve&unstable=
Deno.serve(
{
key: Deno.env.get("NITRO_SSL_KEY"),
cert: Deno.env.get("NITRO_SSL_CERT"),
port: destr(Deno.env.get("NITRO_PORT") || Deno.env.get("PORT")) || 3000,
hostname: Deno.env.get("NITRO_HOST") || Deno.env.get("HOST"),
onListen: (opts) => {
const baseURL = (useRuntimeConfig().app.baseURL || "").replace(/\/$/, "");
const url = `${opts.hostname}:${opts.port}${baseURL}`;
console.log(`Listening ${url}`);
},
// https://deno.land/api@v1.42.4?s=Deno.serve
const serveOptions = {
key: Deno.env.get("NITRO_SSL_KEY"),
cert: Deno.env.get("NITRO_SSL_CERT"),
port: destr(Deno.env.get("NITRO_PORT") || Deno.env.get("PORT")) || 3000,
hostname: Deno.env.get("NITRO_HOST") || Deno.env.get("HOST"),
onListen: (opts) => {
const baseURL = (useRuntimeConfig().app.baseURL || "").replace(/\/$/, "");
const url = `${opts.hostname}:${opts.port}${baseURL}`;
console.log(`Listening ${url}`);
},
handler
);
};

// https://github.com/unjs/nitro/pull/2373
if (!serveOptions.key || !serveOptions.cert) {
delete serveOptions.key;
delete serveOptions.cert;
}

Deno.serve(serveOptions, handler);

// Websocket support
const ws = import.meta._websocket
Expand Down

0 comments on commit ccc3003

Please sign in to comment.