diff --git a/src/runtime/entries/bun.ts b/src/runtime/entries/bun.ts index 0f50d73b8d..c43ebe90cb 100644 --- a/src/runtime/entries/bun.ts +++ b/src/runtime/entries/bun.ts @@ -1,9 +1,21 @@ import "#internal/nitro/virtual/polyfill"; import { nitroApp } from "../app"; + +const options: any = {}; +let listeningOn = ""; + +if (process.env.NITRO_UNIX_SOCKET) { + options.unix = process.env.NITRO_UNIX_SOCKET; + listeningOn = `unix://${process.env.NITRO_UNIX_SOCKET}`; +} else { + options.port = process.env.NITRO_PORT || process.env.PORT || 3000; + listeningOn = `http://localhost:${options.port}` +} + // @ts-expect-error: Bun global const server = Bun.serve({ - port: process.env.NITRO_PORT || process.env.PORT || 3000, + ...options, async fetch(request: Request) { const url = new URL(request.url); @@ -23,4 +35,4 @@ const server = Bun.serve({ }, }); -console.log(`Listening on http://localhost:${server.port}...`); +console.log(`Listening on ${listeningOn}...`);