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

Refactor server url logs #4509

Merged
merged 6 commits into from Sep 21, 2022
Merged

Refactor server url logs #4509

merged 6 commits into from Sep 21, 2022

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Aug 27, 2022

Changes

Close #4315

Vite 3 has an experimental server.resolvedUrls property for the URLs Vite is serving from. It will be stabilize in 3.1 without any API change. vitejs/vite#9866

This PR uses that for the dev server so we closely match the Vite dev server behaviour.

Before:

> astro dev

  πŸš€  astro  v1.1.1 started in 84ms
  
  ┃ Local    http://localhost:3000/
  ┃ Network  use --host to expose
> astro dev "--host"

  πŸš€  astro  v1.1.1 started in 78ms
  
  ┃ Local    http://localhost:3000/
  ┃ Network  http://192.168.0.165:3000/
> astro preview

  πŸš€  astro  v1.1.1 started in 2ms
  
  ┃ Local    http://localhost:3000/
  ┃ Network  use --host to expose

After:

> astro dev

  πŸš€  astro  v1.1.1 started in 82ms
  
  ┃ Local    http://127.0.0.1:3000/
  ┃ Network  use --host to expose
> astro dev "--host"

  πŸš€  astro  v1.1.1 started in 106ms
  
  ┃ Local    http://localhost:3000/
  ┃ Network  http://192.168.0.165:3000/
> astro preview

  πŸš€  astro  v1.1.1 started in 2ms
  
  ┃ Local    http://localhost:3000/
  ┃ Network  use --host to expose

NOTE that the http://127.0.0.1:3000/ change in astro dev after, without the --host option Vite (or Node specifically) would only serve under 127.0.0.1 (ipv4), [::1] (ipv6) isn't served, which could be covered by localhost.

Testing

Tested with the local examples.

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Aug 27, 2022

πŸ¦‹ Changeset detected

Latest commit: d9b3ab4

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

This PR includes changesets to release 16 packages
Name Type
astro Patch
@e2e/astro-component Patch
@e2e/error-cyclic Patch
@e2e/error-react-spectrum Patch
@e2e/error-sass Patch
@e2e/errors Patch
@e2e/hydration-race Patch
@e2e/lit-component Patch
@e2e/preact-component Patch
@e2e/react-component Patch
@e2e/solid-component Patch
@e2e/solid-recurse Patch
@e2e/svelte-component Patch
@e2e/e2e-tailwindcss Patch
@e2e/ts-resolution Patch
@e2e/third-party-astro 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: astro Related to the core `astro` package (scope) label Aug 27, 2022
Copy link
Contributor

@bholmesdev bholmesdev left a comment

Choose a reason for hiding this comment

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

Love aligning with Vite on this behavior! It was a lot to untangle and re-implement when redesigning our own server πŸ˜… Should be good-to-go once tests are passing.

packages/astro/src/core/preview/index.ts Show resolved Hide resolved
@bluwy
Copy link
Member Author

bluwy commented Aug 29, 2022

Ah my bad I didn't realize the tests were failing! That seems like tests errorrs I still have to fix. I'll put this to draft at the meantime, thanks for reviewing 😬

@bluwy bluwy marked this pull request as draft August 29, 2022 16:01
@bluwy
Copy link
Member Author

bluwy commented Sep 5, 2022

The tests should be fixed now. I made the dev server test a bit more relax as there's a difference in output between node <17 and node >=17. The preview server test is unchanged.

@bluwy bluwy marked this pull request as ready for review September 5, 2022 07:48
@matthewp
Copy link
Contributor

@bluwy can you update to resolve the conflicts?

@bluwy
Copy link
Member Author

bluwy commented Sep 13, 2022

Resolved!

@bluwy bluwy added the semver: minor Change triggers a `minor` release label Sep 13, 2022
@matthewp matthewp merged commit a0619f0 into main Sep 21, 2022
@matthewp matthewp deleted the refactor-server-log branch September 21, 2022 17:25
@astrobot-houston astrobot-houston mentioned this pull request Sep 21, 2022
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) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Astro runs on :3000 port even though another app is running on the same port
3 participants