-
Notifications
You must be signed in to change notification settings - Fork 630
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(http): file server prints local network address #4604
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4604 +/- ##
==========================================
- Coverage 91.23% 90.93% -0.31%
==========================================
Files 478 475 -3
Lines 41465 37325 -4140
Branches 5225 5299 +74
==========================================
- Hits 37832 33941 -3891
+ Misses 3568 3330 -238
+ Partials 65 54 -11 ☔ View full report in Codecov by Sentry. |
Side note: This will prints ip address that is not useful to the user in Deno Deploy like:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a test?
Side note: This will prints ip address that is not useful to the user in Deno Deploy like:
Serving static files! local: http://localhost:80 network: http://10.0.0.10:80
This doesn't seem to be the case. The functionality added in this PR is only accessible when running the script directly via deno run -A jsr:@std/http/file-server
because we're using import.meta.main
.
file_server is often used as the entrypoint script in Deploy when serving static site. We even optimize etag generation for Deno Deploy. #3186 |
Now this prints: $ deno run -A http/file_server.ts
Listening on:
- Local: http://localhost:4507
- Network: http://192.168.79.163:4507 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing of this script can be done another time. I created #4605 to track.
const networkAdress = Deno.networkInterfaces().find((i) => | ||
i.family === "IPv4" && !i.address.startsWith("127") | ||
)?.address; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this should be used as the implementation for getNetworkAddress()
.
closes #4597
This PR updates
onListen
hook of file_server to show the local network IP address. The scripts shows 2 urls like the below (Updated):Suggestions to the output format are welcome
Note:
npm:serve
chooses non internal IPv4 address as the network address. This implementation follows it. ref. https://github.com/vercel/serve/blob/1ea55b1b5004f468159b54775e4fb3090fedbb2b/source/utilities/http.ts#L40Note: Deno's NetworkInterfaceInfo object doesn't have
internal
field, but it's polyfilled asaddress.startsWith("127")
in the node compat layer https://github.com/denoland/deno/blob/9acbf90b06bf79dd6e4cf2428b3566da009bed65/ext/node/polyfills/os.ts#L232-L234. This implementation follows it as well.