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

Add option to bind host to 0.0.0.0 #29

Closed
LySofDev opened this issue Jun 1, 2019 · 4 comments
Closed

Add option to bind host to 0.0.0.0 #29

LySofDev opened this issue Jun 1, 2019 · 4 comments

Comments

@LySofDev
Copy link

LySofDev commented Jun 1, 2019

Hello Luke,

I wanted to try out the Svelte project which uses the sirv-cli as development server. I generally run my development environments from within Docker containers which require that a server bind to host 0.0.0.0. Otherwise, my browser is unable to connect to the development server.

I tried using the --cors option to get past this issue but it didn't work. Am I perhaps missing something? Is it possible to bind your current implementation with an undocumented option?

Unfortunately, I had to switch over to a different development server but would like to use the recommend one.

Thank you for your time and awesome package.

@LySofDev
Copy link
Author

LySofDev commented Jun 1, 2019

Unless you have a reason not too, you could probably add the option and pass the host as the second argument to the server.listen call.

server.listen(port, err => {

Node docs indicate that the second optional argument is the host.

https://nodejs.org/api/net.html#net_server_listen

@lukeed
Copy link
Owner

lukeed commented Jun 1, 2019

Yes, for sure! I thought it was in there already but guess not.

I'll get it in tonight unless you want to beat me to it. Currently away from my computer - back soon

@lukeed lukeed closed this as completed in 210302e Jun 1, 2019
@lukeed
Copy link
Owner

lukeed commented Jun 1, 2019

Hey, thanks

So I took care of --host, -H support. While I was at it, I added support for HOST and PORT environment variables, which also should have been there.

These options are now available in sirv-cli@0.4.3:

$ PORT=3000 sirv public
$ HOST=0.0.0.0 sirv public
$ sirv public --host 10.0.0.1

@LySofDev
Copy link
Author

LySofDev commented Jun 1, 2019

Thanks! 👍

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

No branches or pull requests

2 participants