[Bug]: Cannot use in devcontainer (Docker) because of local ip address in socket.io URL
Closed this issue ยท 6 comments
Version
System:
OS: Linux 6.5 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
CPU: (10) arm64 unknown
Memory: 40.75 GB / 46.97 GB
Container: Yes
Shell: 5.1.4 - /bin/bash
npmPackages:
@rsdoctor/rspack-plugin: ^0.1.0 => 0.1.0
Details
The URL displayed in stdout (Rsdoctor analyze run at: http://172.17.0.2:4409/index.html
) use the local ip address (npm ip
package)... when trying to workaround by replacing in the browser the IP address by localhost
, the page is displaying, but the socket.io cannot connect because an absolute URL is used...
The possible fixes could be:
- Use
localhost
- Use relative URL for socket.io (
/socket.io/?EIO=xxxx
) - Create a config parameter (
serverBaseUrl
or whatever...)
Reproduce link
VSCode devcontainer
Reproduce Steps
Launch in any docker container and display page in a host's browser
Thanks, I got this issue, i will try to fix this.
@my-lalex hi, I want to know the reason why you need to workaround by replacing in the browser the IP address by localhost.
This is because you don't want to exposed the machine ip or other reason ?
If I show both localhost:port/ and ip:port/ in stdout , this would resolve your problem?
Hey!
Actually, the frontend is using an absolute URL to connect to socket.io so just changing the console output won't be enough...
As I previously said, using a /socket.io/xxxxx in the front end can be a simple and effective fix... (option 2)
Option 1 (localhost) could be limited for user working on remote hosts...
(it was me on the previous comment, switched pro/perso account ๐)
And displaying localhost in the stdout is helpful too: it allows to not have to change the URL in the browser and just click the link...
A docker container has its own IP (the one currently used by RSdoctor) which is not reachable from the host, so it can't be used to access rsdoctor in a devcontainer...
Maybe the webserver should bind 0.0.0.0 and the frontend use relative URLs (actually absolute, but without protocol://host:port
) to be more portable...
I got it, I'll fix this soon.