Skip to content

Astro preview --host doesn't work as expected #13034

@Antonytm

Description

@Antonytm

Astro Info

Astro                    v5.1.8
Node                     v20.12.0
System                   Windows (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/react

If this issue only occurs in one browser, which browser is a problem?

Any browser

Describe the Bug

I want to run astro preview and make it available on all IP addresses.

I tried npm run astro preview --host and I tried astro.config.mjs server>host set to true.

e.g. for astro preview --host I get:

20:30:34 [@astrojs/node] Server listening on
  local: http://localhost:3000
  network: http://192.168.88.23:3000

And if I try to open http://192.168.88.23:3000 in browser, I get nothing.

But if I run astro dev --host, I have different results:

 astro  v5.1.8 ready in 332 ms

┃ Local    http://localhost:3000/
┃ Network  http://192.168.88.23:3000/
           http://172.23.96.1:3000/
           http://172.19.176.1:3000/

And any IP address is available from the browser.

What's the expected result?

Ability to use astro preview with --host flag in the same way as astro dev

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-rnmmfmc9?file=package.json,astro.config.mjs&on=stackblitz

Participation

  • I am willing to submit a pull request for this issue.

Added details

The issue is only reproducible with astrojs/node adapter. Sample astro configuration:

// @ts-check
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';

// https://astro.build/config
export default defineConfig({
  server: {
    host: true,
  },
  output: 'server',
  adapter: node({
    mode: 'standalone',
  }),
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)pkg: nodeRelated to Node adapter (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions