lisonge / vite-plugin-monkey

A vite plugin server and build your.user.js for userscript engine like Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat
MIT License
1.24k stars 65 forks source link

`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? #116

Closed snomiao closed 7 months ago

snomiao commented 7 months ago

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:

Expected:

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.

lisonge commented 7 months ago

https://github.com/lisonge/vite-plugin-monkey/releases/tag/v3.5.1