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

Showing available alternative IP when running dev server. #4027

Closed
wants to merge 2 commits into from
Closed

Showing available alternative IP when running dev server. #4027

wants to merge 2 commits into from

Conversation

glemiere
Copy link

@glemiere glemiere commented Mar 19, 2018

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.

@glemiere
Copy link
Author

#4025

@glemiere glemiere changed the title Showing available alternative IP when running dev server, as an alter… Showing available alternative IP when running dev server. Mar 19, 2018
bin/next-dev Outdated

// Print the result
if (address) {
console.log('\x1b[32m', '> Network interface detected: ', address, '\x1b[37m')
Copy link
Author

@glemiere glemiere Mar 19, 2018

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')
Copy link
Author

@glemiere glemiere Mar 19, 2018

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.

@timneutkens
Copy link
Member

timneutkens commented Mar 19, 2018

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 --hostname in the readme.md.

@glemiere
Copy link
Author

glemiere commented Mar 19, 2018

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.

@Alfrex92
Copy link

Is next - - hostaname the command?
Or can I use a local IP instead of local host?

@lock lock bot locked as resolved and limited conversation to collaborators Jul 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants