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

elm-watch beta: CLI gives https:// links by default in Bun #100

Open
upsiflu opened this issue Jun 1, 2024 · 6 comments
Open

elm-watch beta: CLI gives https:// links by default in Bun #100

upsiflu opened this issue Jun 1, 2024 · 6 comments

Comments

@upsiflu
Copy link

upsiflu commented Jun 1, 2024

When I run elm-watch hot, it gives me https:// links instead of http://

It's just a minor annoyance. I have to change the URL manually to http://, then it works fine. I didn't find any configuration option to force http://.

Console output (with https instead of http):

✅ Dependencies
✅ Main                                                                 0 ms Q |  48 ms T ¦   2 ms W

📊 server: https://localhost:51572, network: https://192.168.62.200:51572
📊 web socket connections: 0

✅ 19:54:32 Compilation finished in 641 ms.

elm-watch.json:

{
    "targets": {
        "Main": {
            "inputs": [
                "src/Main.elm"
            ],
            "output": "public/main.js"
        }
    },
    "serve": "public/"
}

public/index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>example-minimal</title>
  </head>
  <body>
    <div id="root"></div>
    <script src="/main.js"></script>
    <script>
      Elm.Main.init({ node: document.getElementById("root") });
    </script>
  </body>
</html>
@lydell
Copy link
Owner

lydell commented Jun 1, 2024

Hi! The printed links are only supposed to be HTTPS links if you have passed in an HTTPS custom server. A quick test right now gave me HTTP links, so it looks like I’m missing something that is different on your computer.

@almereyda
Copy link

almereyda commented Jun 3, 2024

I can reproduce the behaviour as described by @upsiflu when checking out the repository and following the instructions at lab.allmende.io/libernetes/libernet.es.

ghq get https://lab.allmende.io/libernetes/libernet.es
cd ~/src/lab.allmende.io/libernetes/libernet.es
mkdir -p public
asdf plugin add bun
asdf plugin add just
asdf install
bun --bun install
just dev
✅ Dependencies
   ● Chadtech/elm-bool-extra 2.4.2
   ● elm-community/maybe-extra 5.3.0
   ● elm/virtual-dom 1.0.3
   ● elm/parser 1.1.0
   ● dillonkearns/elm-markdown 7.0.1
   ● rtfeldman/elm-hex 1.0.0
   ● elm-community/list-extra 8.7.0
   ● stoeffel/set-extra 1.2.3
   ● stil4m/structured-writer 1.0.3
   ● elm-community/string-extra 4.0.1
   ● Fresheyeball/elm-return 7.1.0
   ● linuss/smooth-scroll 1.1.0
   ● elm-explorations/test 2.2.0
   ● elm-community/easing-functions 2.0.0
   ● pablohirafuji/elm-syntax-highlight 3.5.0
   ● pzp1997/assoc-list 1.0.0
   ● turboMaCk/non-empty-list-alias 1.4.0
   ● elm/project-metadata-utils 1.0.2
   ● miniBill/elm-unicode 1.1.1
   ● jfmengels/elm-review 2.13.2
   ● stil4m/elm-syntax 7.3.2
   ● edkelly303/elm-any-type-forms 5.0.0
   ● lue-bird/elm-review-single-use-type-vars-end-with-underscore 2.0.3
   ● upsiflu/less-ui 2.0.0
✅ Main                                                                 0 ms Q |  68 ms T ¦   4 ms W

📊 server: https://localhost:53205, network: https://10.30.30.9:53205, network: https://100.64.0.7:53205, network: https://172.20.0.1:53205
📊 web socket connections: 0

✅ 10:23:34 Compilation finished in 5.99 s.

With just dev being a shorthand for bun run --bun elm-watch hot:

$ cat justfile
dev:
    cp -R static/* public/
    bun run --bun elm-watch hot
…

On the contrary to what is printed by the command output, the website will be available on http://localhost:53205/ instead.

@lydell
Copy link
Owner

lydell commented Jun 3, 2024

Does it happen if you:

  • Don’t use just?
  • Use node instead of bun?

@upsiflu
Copy link
Author

upsiflu commented Jun 3, 2024

Yes!

Using node instead of bun solved the issue:

bun run elm-watch hot instead of bun run --bun elm-watch hot

Thank you @lydell

@lydell
Copy link
Owner

lydell commented Jun 3, 2024

Thanks you for narrowing down the problem! Then it’s either a bun bug, or that we need to find some other way of detecting if we’re running an HTTP or HTTPS server. This is the current check:

this.isHTTPS = this.polyHttpServer instanceof https.Server;

@almereyda
Copy link

Interesting find. I will be curious to learn what causes the difference with the two upstreams.

@lydell lydell changed the title elm-watch beta: CLI gives https:// links by default elm-watch beta: CLI gives https:// links by default in Bun Jun 10, 2024
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

3 participants