如何连接到在代码任何地方运行的 webpack 开发服务器



我在连接到代码中运行的 webpack 开发服务器时遇到问题。我的 webpack.config 中有以下内容.js:

devServer: {
// "disableHostCheck" added due to issue: https://github.com/webpack/webpack-dev-server/issues/1604
// Fix should be done with: https://github.com/webpack/webpack-dev-server/pull/1608
disableHostCheck: true,
headers: {
'Access-Control-Allow-Origin': '*'
},
host: '0.0.0.0',
allowedHosts: [
'.codeanyapp.com'
],
public: 'port-4200.<container-address>.codeanyapp.com'

}

这些是开发服务器启动参数:

--https --port 4200

我在以下任一 URL 上都没有成功:

http://port-4200.<container-address>.codeanyapp.com/
https://port-4200.<container-address>.codeanyapp.com/

有什么想法接下来要尝试什么吗?

编辑:看起来像一个https问题,我可以让服务器通过http说话。知道正确的openssl参数是什么来生成在chrome中工作的自签名证书吗?

我遇到了同样的问题。为我修复它的是在 webpack.config 中设置 devServer 属性.js如下所示:

devServer: {
host:'0.0.0.0',
port: 4200,
contentBase: path.join(__dirname, [your path]),
watchContentBase: true,
compress: true,
disableHostCheck: true
}

最新更新