我通过npm为我的网站项目更新了模块,并试图像往常一样通过Chrome Web浏览器的[https://127.0.0.1:8000“访问我的网站]
加载网站后,我收到以下错误:
sockjs.js:689未捕获的错误:SecurityError:可能无法通过HTTPS加载的页面启动不安全的SockJS连接
这里是完整的错误堆栈跟踪:
Uncaught Error: SecurityError: An insecure SockJS connection may not be initiated from a page loaded over HTTPS
at new SockJS (sockjs.js:689)
at new SockJSClient (webpack:///(:8000/webpack)-dev-server/client/clients/SockJSClient.js?:39:18)
at initSocket (webpack:///(:8000/webpack)-dev-server/client/socket.js?:20:12)
at Object.eval (webpack:///(:8000/webpack)-dev-server/client?:176:1)
at eval (webpack:///(:8000/webpack)-dev-server/client?:177:30)
at Object../node_modules/webpack-dev-server/client/index.js?http://0.0.0.0:8081 (bundle.9c58b1f21bf6b7e8db3b.js:9362)
at __webpack_require__ (bundle.9c58b1f21bf6b7e8db3b.js:727)
at fn (bundle.9c58b1f21bf6b7e8db3b.js:101)
at eval (webpack:///multi_(:8000/webpack)-dev-server/client?:1:1)
at Object.0 (bundle.9c58b1f21bf6b7e8db3b.js:10997)
非常感谢您的帮助!
谢谢
您必须在webpack.config.js中配置https看here
module.exports = {
//...
devServer: {
https: {
key: fs.readFileSync('/path/to/server.key'),
cert: fs.readFileSync('/path/to/server.crt'),
ca: fs.readFileSync('/path/to/ca.pem'),
}
}
};