Skip to content

NITRO_HOST not working when using preset: "bun" in Nuxt #3546

Closed

Description

@wling-art

Environment

bun: 1.2.20
nitro: 2.12.4
nuxt: 4.0.3
nodejs: v24.4.0

Reproduction

https://github.com/nitrojs/nitro/blob/v2/src/presets/bun/runtime/bun.ts#L14-L41

Describe the bug

When using Nuxt with Nitro and setting:

preset: "bun"

I noticed that NITRO_HOST has no effect — only NITRO_PORT works.

In the built index.mjs, the Bun server is started like this:

me = Bun.serve({
    port: t.env.NITRO_PORT || t.env.PORT || 3e3,
    websocket: de.websocket,
    async fetch(t, e) {
        if ("websocket" === t.headers.get("upgrade"))
            return de.handleUpgrade(t, e);
        const s = new URL(t.url);
        let c;
        if (t.body) c = await t.arrayBuffer();
        return ue.localFetch(s.pathname + s.search, {
            host: s.hostname,
            protocol: s.protocol,
            headers: t.headers,
            method: t.method,
            redirect: t.redirect,
            body: c
        });
    }
});

As you can see, only the port option is read from the environment.
NITRO_HOST is never used, so there’s no way to set a custom host — it always binds to the default.

Additional context

https://github.com/nitrojs/nitro/blob/v2/src/presets/bun/runtime/bun.ts#L14-L41

Logs

Activity

  1. added
    pending triage
    on Aug 25, 2025
  2. wling-art commented on Aug 26, 2025

    @wling-art
    ContributorAuthor

    fix #3547

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions