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

Adding --host to script is not exposing server on network #4947

Closed
yousufiqbal opened this issue May 16, 2022 · 4 comments · Fixed by #4949
Closed

Adding --host to script is not exposing server on network #4947

yousufiqbal opened this issue May 16, 2022 · 4 comments · Fixed by #4949
Labels
bug Something isn't working

Comments

@yousufiqbal
Copy link
Contributor

Describe the bug

I'm on Windows 10. On starting fresh repo using npm init svelte and then adding --host to dev in scripts is not exposing server to other devices on network.

{
  "name": "abcd",
  "version": "0.0.1",
  "scripts": {
    "dev": "svelte-kit dev --host",
    "build": "svelte-kit build",
    "package": "svelte-kit package",
    "preview": "svelte-kit preview",
    "prepare": "svelte-kit sync",
    "check": "svelte-check --tsconfig ./jsconfig.json",
    "check:watch": "svelte-check --tsconfig ./jsconfig.json --watch",
    "lint": "eslint --ignore-path .gitignore ."
  },
  "devDependencies": {
    "@sveltejs/adapter-auto": "next",
    "@sveltejs/kit": "next",
    "eslint": "^8.12.0",
    "eslint-plugin-svelte3": "^4.0.0",
    "svelte": "^3.44.0",
    "svelte-check": "^2.2.6",
    "typescript": "~4.6.2"
  },
  "type": "module"
}

Terminal output

> abcd@0.0.1 dev
> svelte-kit dev --host


  SvelteKit v1.0.0-next.331

  network: not exposed
  local:   http://localhost:3000

  Use --host to expose server to other devices on this network

The issue seems to be tied with next.331. I cannot reproduce this on next.330

Reproduction

https://github.com/yousufiqbal/host-issue-repo.git

Logs

> abcd@0.0.1 dev
> svelte-kit dev --host


  SvelteKit v1.0.0-next.331

  network: not exposed
  local:   http://localhost:3000

  Use --host to expose server to other devices on this network

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (4) x64 Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz
    Memory: 383.09 MB / 3.90 GB
  Binaries:
    Node: 16.15.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.10.0 - C:\Program Files\nodejs\npm.CMD  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (101.0.1210.47)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.43
    @sveltejs/kit: next => 1.0.0-next.331
    svelte: ^3.44.0 => 3.48.0

Severity

blocking all usage of SvelteKit

Additional Information

No response

@yousufiqbal yousufiqbal changed the title Adding --host to scriptd is not exposing server on network Adding --host to script is not exposing server on network May 16, 2022
@yousufiqbal
Copy link
Contributor Author

I found that using svelte-kit dev --host 0.0.0.0 makes it work. But that wasn't the case before. Only adding --host to scripts worked previous. If it is intended, maybe it should be documented.

@Conduitry
Copy link
Member

Yup, can confirm this is happening. I think --host alone (without a host after it) should continue to listen on all interfaces. I imagine this was a result of #4932.

@Conduitry Conduitry added the bug Something isn't working label May 16, 2022
@Conduitry
Copy link
Member

Conduitry commented May 16, 2022

With the new default for host specified in https://github.com/sveltejs/kit/pull/4932/files#diff-3d3392afaae8a848f5862f73d4cfa9e50f984b68ecd1d91f6c414ece0de4f23bR52, when --host is specified without an argument, the host variable is now an empty string, rather than true.

@bluwy Is there a particular reason to have 'localhost' be the default for this option? Should we revert that part of the change, or should we make the rest of the codebase treat host equal to an empty string as exposing the server on all interfaces? The preview command already does this, so we could presumably borrow the logic for correctly handling the empty string from there.

@bluwy
Copy link
Member

bluwy commented May 16, 2022

Yeah I'm checking this out too and it seems to be the case. I've set it to localhost mostly so that it's consistent with preview. I think "host equal empty string => expose" makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants