Skip to content

Document --host and --port flag for preview#9572

Merged
bluwy merged 1 commit intomainfrom
add-preview-help
Jan 2, 2024
Merged

Document --host and --port flag for preview#9572
bluwy merged 1 commit intomainfrom
add-preview-help

Conversation

@bluwy
Copy link
Copy Markdown
Member

@bluwy bluwy commented Jan 2, 2024

Changes

Ref: #9133 (comment)

We support those flags for all adapters as we collect them here

export default async function preview(inlineConfig: AstroInlineConfig): Promise<PreviewServer> {
const logger = createNodeLogger(inlineConfig);
const { userConfig, astroConfig } = await resolveConfig(inlineConfig ?? {}, 'preview');

And then pass them to adapters at:

const server = await previewModule.default({
outDir: settings.config.outDir,
client: settings.config.build.client,
serverEntrypoint: new URL(settings.config.build.serverEntry, settings.config.build.server),
host: getResolvedHostForHttpServer(settings.config.server.host),
port: settings.config.server.port,
base: settings.config.base,
logger: new AstroIntegrationLogger(logger.options, settings.adapter.name),
});

Testing

Tested manually in the examples app:

> @example/ssr@0.0.1 preview /Users/bjorn/Work/oss/astro/examples/ssr
> astro preview "--port" "4444" "--host"

15:54:49 [@astrojs/node] Preview server listening on 
  local: http://localhost:4444 
  network: http://192.168.68.55:4444
> @example/basics@0.0.1 preview /Users/bjorn/Work/oss/astro/examples/basics
> astro preview "--port" "4444" "--host"


 astro  v4.0.8 ready in 5 ms

┃ Local    http://localhost:4444/
┃ Network  http://192.168.68.55:4444/

Docs

Looks like it's only documented for astro dev: https://docs.astro.build/en/reference/cli-reference/#astro-dev

It should be updated.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 2, 2024

🦋 Changeset detected

Latest commit: bb310e3

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review labels Jan 2, 2024
@bluwy bluwy merged commit 9f6453c into main Jan 2, 2024
@bluwy bluwy deleted the add-preview-help branch January 2, 2024 09:45
@astrobot-houston astrobot-houston mentioned this pull request Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants