0

我在连接到在 codeanywhere 中运行的 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 中工作的自签名证书吗?

4

1 回答 1

0

我遇到过同样的问题。为我解决的问题是在 webpack.config.js 中设置 devServer 属性,如下所示:

devServer: {
  host:'0.0.0.0',
  port: 4200,
  contentBase: path.join(__dirname, [your path]),
  watchContentBase: true,
  compress: true,
  disableHostCheck: true
}
于 2020-04-22T20:04:33.163 回答