Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly handle wildcard hosts in preview #514

Merged
merged 1 commit into from
Jan 22, 2025
Merged

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Jan 22, 2025

Changes

Currently the Node adapter doesn't correctly handle the host option in preview.

This PR updates the adapter to use the same host rules as the astro core preview server:

  • false or unset uses default of localhost
  • true uses wildcard host (0.0.0.0), meaning listen on all available host interfaces
  • undefined (only set by using the cli flag with no argument) uses wildcard
  • any other value uses that as the host

Fixes withastro/astro#13034

Testing

Adds test suite

Docs

Copy link

changeset-bot bot commented Jan 22, 2025

🦋 Changeset detected

Latest commit: 9017169

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

This PR includes changesets to release 15 packages
Name Type
@astrojs/node Patch
@test/nodejs-api-route Patch
@test/nodejs-badurls Patch
@test/nodejs-encoded Patch
@test/nodejs-errors Patch
@test/nodejs-headers Patch
@test/nodejs-image Patch
@test/locals Patch
@test/node-middleware Patch
@test/nodejs-prerender-404-500 Patch
@test/nodejs-prerender Patch
@test/nodejs-preview-headers Patch
@test/node-trailingslash Patch
@test/url Patch
@test/well-known-locations Patch

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 the pkg: node Related to Node adapter (scope) label Jan 22, 2025
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ascorbic ascorbic merged commit ea4297b into main Jan 22, 2025
8 checks passed
@github-actions github-actions bot mentioned this pull request Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: node Related to Node adapter (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Astro preview --host doesn't work as expected
2 participants