-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Showing available alternative IP when running dev server. #4027
Conversation
…native to localhost
bin/next-dev
Outdated
|
||
// Print the result | ||
if (address) { | ||
console.log('\x1b[32m', '> Network interface detected: ', address, '\x1b[37m') |
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.
Anybody with write access could like to replace the ' by ` to match other console.logs format.
bin/next-dev
Outdated
// Print the result | ||
if (address) { | ||
console.log('\x1b[32m', '> Network interface detected: ', address, '\x1b[37m') | ||
console.log('> If you wish to use this address instead of localhost, run this command again with "--hostname ' + address + '" ', '\x1b[37m') |
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.
I guess it would be better to merge these two console.log and use a "\n" to separate the lines. Also the last '\x1b[37m' is absolutely useless. Damn yellow plastic duck.
I don't think the added overhead to next-dev is worth it, since setting the hostname is not common. All that's needed is documentation for |
I get it, but getting an available address is pretty useful. In fact not having it makes the hostname param incomplete, because on one hand you offer this possibility to the developer, and on another hand this developer has to figure out himself which address to use, which can be challenging, especially for beginners, or developers that are not familiar with the network they are using and the methods to retrieve an available IP. NextJS is great to earn time with all the configuration mess, I think this PR goes pretty much along with the philosophy of this repo. The ionic CLI is doing it and I’m using it often as it is useful for cross platform development. I’ve always appreciated this feature and I think the hostname flag might be used a little more if this feature is added, because it's making the hostname param concept friendlier ;) I did think that the hostname feature might not be used enough to justify a prompt to ask the developer if he wishes to switch to an IP instead of localhost, but showing an available IP during compilation doesn't sounds crazy to me. |
Is next - - hostaname the command? |
This small code is intended to make it easier for developers to use an alternative IP instead of localhost by directly showing an available IP to use, as well as the argument required while using the dev server.
This is particularly useful if you want to be able to check the result of your work on multiple devices at the same time, like from your laptop and your smart phone.