Closed borekb closed 5 years ago
So maybe with HTTPS, only the first two links should be given? Or could the certificate be updated to work with the specific IP URL as well?
Yeah, good point. The first option is possible. I'm not sure about the second, I'll look into that too.
Displaying the external IP (e.g. https://192.168.1.163:8000
) is useful for people testing web applications from a mobile device on the local network.
How about something like this?
$ ws --https
Serving at https://localhost:8000
To test on mobile devices from local network, visit https://192.168.1.163:8000
The primary URL could also be green or something.
Regarding the last address (https://192.168.1.163:8000) not being covered by the default lws certificate, there's not much I can do about that. The 192.168.x.x
IP will be different for every user so I can't create a standardised lws cert which covers every IP permutation (unless you know a way, in which case please share).
You would need to create a cert for your own specific needs: https://github.com/lwsjs/local-web-server/wiki/How-to-get-the-%22green-padlock%22-with-a-new-self-signed-certificate
You can use --hostname
to bind to a single address.
$ ws --https --hostname localhost
Listening on https://localhost:8000
When I run
ws
, I get this message:From this, I randomly chosen the last URL given only to encounter the "Your connection is not secure" issue in Chrome. I thought I've got my certificate misconfigured but then I noticed this in the imported
lws
certificate in macOS Keychain Access:So I tried the
127.0.0.1
address and it worked, as well aslocalhost
. (It still didn't work in Firefox but maybe they handle certificates differently, I don't know, I care mostly about Chrome.)So maybe with HTTPS, only the first two links should be given? Or could the certificate be updated to work with the specific IP URL as well?
(Additional piece of feedback: for my purposes, I'd be more than happy with a single URL; receiving multiple doesn't make much sense in my scenarios. I guess that's for remote access via network but I never tried that; if that's not very common, maybe it could be hidden behind a flag to make the UX cleaner.)