`vite --host 0.0.0.0` is not working, due to host 0.0.0.0 is replaced into 127.0.0.1, and why?
Closed this issue · 1 comments
snomiao commented
I am running vite inside docker so I need to proxy the vite port from another http service.
version 3.5.0 • Public • Published 4 months ago
Current:
vite --host
-- not working ❌, will listen to 127.0.0.1vite --host 0.0.0.0
-- not working ❌, will listen to 127.0.0.1vite --host 172.21.0.5
-- it works ✅
Expected:
vite --host
-- works ✅vite --host 0.0.0.0
-- works ✅vite --host 172.21.0.5
-- it works ✅
Possible Reason
vite --host 0.0.0.0
is not working
And that is because of this file:
// packages/vite-plugin-monkey/src/node/plugins/server.ts
get host() {
if (
typeof viteConfig.server.host == 'string' &&
viteConfig.server.host != '0.0.0.0'
) {
return viteConfig.server.host;
}
return '127.0.0.1';
},
when getting --host args, '0.0.0.0' or true is replaced with '127.0.0.1'
Workaround for host on LAN
run ifconfig and got the IP address from docker, then pass it into --host argument.
vite --host 172.21.0.5
-- it works ✅