如何使用外部IP访问webpack-dev-server

6

我已经完整地编写并在Webpack开发服务器上运行了我的简单登录网站。如何使用我的外部IP显示它?我已经将路由器端口转发到9000端口,但当我尝试使用www.myIp:portnumber时,它不起作用。

以下是Webpack开发服务器的配置:

//Webpack config
module.exports = {
  entry: './app/main.js',
  output: {
    path: './app',
    filename: 'bundle.js'
  },
  devServer: {
    inline: true,
    contentBase: './app',
    port: 9000
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel'
      }
    ]
  }
}

你可以通过传递 --host 选项来打开它。 webpack-dev-server --port 3000 --hot --host 0.0.0.0 https://github.com/webpack/webpack-dev-server/issues/147 - zloctb
1个回答

12

1
非常感谢,这解决了我的问题。之后我只需要禁用webpack-dev-server中实现的新Hostcheck,现在我可以从外部访问它了! - Eric

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接