vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

Vue-cli 5 open 0.0.0.0:9000 instead of localhost:9000 #6834

Open Makio64 opened 2 years ago

Makio64 commented 2 years ago

Version

5.0.0-rc.0

Reproduction link

github.com/vuejs/vue-cli

Environment info

Windows 11

Steps to reproduce

Start a new vue-cli5.0 on windows

What is expected?

Open one the correct url :

What is actually happening?

Open http://0.0.0.0:9000


everything was working fine on vue-cli4. My devserver on my webpack config 5 for no vuejs experiments looks like this :

    devServer: {
        open: true,
        compress: true,
        https: true,
        hot: true,
        allowedHosts: 'all',
        historyApiFallback: true,
        port: 9000,
        host: 'local-ip',
        static: {
            directory: path.resolve(__dirname, './app'),
            staticOptions: {},
            watch: true,
        },

    },

important parameter I change when i switch from v4 to v5 :
host: 'local-ip',

fengyuanchen commented 2 years ago

The same question here, use @vue/cli@5.0.0-rc.1, without any extra config in the vue.config.js, when run vue-cli-service serve --open, I also open the 0.0.0.0:8080, but not localhost:8080 as Vue CLI 4.

YFengFly commented 2 years ago

I had a similar problem.

It is also Windows 11, Vue CLI 5.00-rc.1, When only open: true is set, it will automatically openhttp://0.0.0: 8080/ first, but it will be reported as:

App running at:

Although it is not a big problem, I always feel confused, and I still hope to be consistent.


我也遇到了类似的问题。

同样是 Windows 11, Vue CLI 5.00-rc.1, 当只设置了 open: true 会先自动打开 http://0.0.0.0:8080/ ,但 server 启动成功后会报告为:

App running at:

尽管无伤大雅,却总觉困惑,还是希望能够统一的。

yoyo837 commented 2 years ago

Same here.

TothingWay commented 2 years ago

When will this problem be fixed?

JonUleis commented 2 years ago

Still happening on vue-cli 5.0.4. On Windows, yarn serve --open opens a browser tab to http://0.0.0.0:8080 which results in a 404.

Mr-xzq commented 2 years ago

Still happening on vue-cli 5.0.4. On Windows, run command: vue-cli-service serve, first opens a browser tab to http://0.0.0.0:port/ which results in a 404.

erezmus commented 2 years ago

you need to specify the host option, e.g.

vue-cli-service serve --open --host localhost
DuSenYao commented 2 years ago

maybe it works

const port = process.env.port || 7878;

devServer: {
    port,
    open: {
      target: [`http://localhost:${port}`]
    }
}
eaglejs commented 2 years ago

This appears to still be an issue. Overriding --host shouldn't be the solution. The reason we use 0.0.0.0 is to allow all incoming traffic for testing purposes. This is really useful when using containers.

DuSenYao commented 2 years ago

This is not changed --host.To open a specified page in a browser.

TothingWay commented 2 years ago

If the port number is occupied, it is still open: http://localhost:7878

DuSenYao commented 2 years ago

There is a problem with my code. Need to change http://localhost:${port} to http://localhost.

TothingWay commented 2 years ago

There is a problem with my code. Need to change http://localhost:${port} to http://localhost.

This will not open the page correctly

DuSenYao commented 2 years ago

If this method doesn't work, you can only change the port manually.

TothingWay commented 2 years ago

ok,thx

Lixianlai-2 commented 2 years ago

works!

markIV747 commented 1 year ago

you need to specify the host option, e.g.

vue-cli-service serve --open --host localhost

thank you it works <3

lefreet commented 1 year ago

any plan ?

Amirioelmos commented 1 year ago

in package.json set this line:

    "serve": "vue-cli-service serve --host 0.0.0.0",