Skip to content
Discussion options

You must be logged in to vote

The output at .output/server/index.mjs from the bun preset is self-contained: it calls Bun.serve() the moment it gets imported. "Programmatic" here is just a dynamic import with the env vars set beforehand.

// cli/serve.ts
import { parseArgs } from "util"

const { values } = parseArgs({
  args: Bun.argv,
  options: {
    port: { type: "string", default: "3000" },
    host: { type: "string", default: "0.0.0.0" },
  },
  strict: false,
  allowPositionals: true,
})

process.env.PORT = values.port
process.env.HOST = values.host

await import("./.output/server/index.mjs")
console.log(`serving on http://${values.host}:${values.port}`)

Run it: bun cli/serve.ts --port 8080.

Env vars Nitro reads: P…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by eyueldk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants