diff --git a/src/presets/deno-server.ts b/src/presets/deno-server.ts index ee72ec3625..7684f73bb7 100644 --- a/src/presets/deno-server.ts +++ b/src/presets/deno-server.ts @@ -23,7 +23,7 @@ export const denoServer = defineNitroPreset({ clearInterval: ["node:timers", "clearInterval"], setImmediate: ["node:timers", "setImmediate"], clearImmediate: ["node:timers", "clearImmediate"], - process: ["node:process", "default"], + // process: ["node:process", "default"], }, }, rollupConfig: { diff --git a/src/runtime/entries/deno-server.ts b/src/runtime/entries/deno-server.ts index e81fea4ed7..239ba8930a 100644 --- a/src/runtime/entries/deno-server.ts +++ b/src/runtime/entries/deno-server.ts @@ -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