我正在使用Symfony和Encore为我的Web项目。节点版本为20.5.0。我最近买了一台新的macbook m2,并安装了node和所有的东西。但是当运行Encore服务器(webpack dev服务器)时,我遇到了这个问题:
➜ project git:(dev) ✗ NODE_OPTIONS=--openssl-legacy-provider npm run dev
> encore dev-server --open https://127.0.0.1:8000
Running webpack-dev-server ...
<i> [webpack-dev-server] SSL certificate: /Users/.../web/.../node_modules/.cache/webpack-dev-server/server.pem
[webpack-cli] Error: not enough data
at configSecureContext (node:internal/tls/secure-context:280:15)
at Object.createSecureContext (node:_tls_common:116:3)
at Server.setSecureContext (node:_tls_wrap:1439:27)
at Server (node:_tls_wrap:1303:8)
at new Server (node:https:75:3)
at Object.createServer (node:https:131:10)
at Server.createServer (/Users/.../web/.../node_modules/webpack-dev-server/lib/Server.js:2528:57)
at Server.initialize (/Users/.../web/.../node_modules/webpack-dev-server/lib/Server.js:1893:10)
at Server.start (/Users/.../web/.../node_modules/webpack-dev-server/lib/Server.js:3358:16)
at async Command.<anonymous> (/Users/.../web/.../node_modules/@webpack-cli/serve/lib/index.js:242:25)
字符串
webpack.config.js
.configureDevServerOptions(options => {
options.server = {
type: 'https',
options: {
pfx: path.join(process.env.HOME, '.symfony5/certs/default.p12'),
}
}
})
型
1条答案
按热度按时间kmbjn2e31#
我错过了设置symfony服务器使用TLS的步骤。通过运行以下命令修复:
字符串
在this documentation中声明