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

feat: public option and --host flag to disable network expose in development by default #98

Merged
merged 4 commits into from
Aug 12, 2023

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Aug 12, 2023

πŸ”— Linked issue

resolves #88

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR introduces a new public option (available as --host cli flag implicitly with vite cli consistancy) that controls whether by default we should listen to the public network interfaces or not.

If the option is not explicitly being set, we infer it first by checking (explicit) hostname if being localhost to disable and then fallback to env check and only enable public by default for production (more compatibility) and disable for development (more security).

I suppose this is a safe nonbreaking change especially since we keep production behavior as-is, support and show --host flag and anyway main consumers (nuxt and nitro) are introducing this feature in the non major version. But also open to make development default and release a major version if too much trouble in the ecosystem happened which I guess won't unless there is a special complex setup. /cc @danielroe @antfu

image

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@pi0 pi0 requested review from antfu and danielroe August 12, 2023 16:16
@pi0 pi0 changed the title feat: public/--public option and disable network expose in development by default feat: public and --public option and disable network expose in development by default Aug 12, 2023
@codecov
Copy link

codecov bot commented Aug 12, 2023

Codecov Report

Merging #98 (48f29c4) into main (aba93a8) will decrease coverage by 2.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #98      +/-   ##
==========================================
- Coverage   51.70%   49.67%   -2.04%     
==========================================
  Files          10       10              
  Lines        1497     1516      +19     
  Branches      111      101      -10     
==========================================
- Hits          774      753      -21     
- Misses        723      763      +40     
Files Changed Coverage Ξ”
src/listen.ts 83.10% <100.00%> (-9.62%) ⬇️
src/types.ts 100.00% <100.00%> (ΓΈ)

... and 1 file with indirect coverage changes

@pi0 pi0 changed the title feat: public and --public option and disable network expose in development by default feat: public option and --host flag to disable network expose in development by default Aug 12, 2023
@pi0 pi0 merged commit 70cc93a into main Aug 12, 2023
3 of 4 checks passed
@pi0 pi0 deleted the feat/no-public branch August 12, 2023 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable public listhen by default in dev
1 participant