出现以下报错是因为对应https网站没有受信任的证书
Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: IP: 112.60.33.18 is not in the cert's list:
at new NodeError (node:internal/errors:405:5)
at Object.checkServerIdentity (node:tls:337:12)
at TLSSocket.onConnectSecure (node:_tls_wrap:1669:27)
at TLSSocket.emit (node:events:517:28)
at TLSSocket._finishInit (node:_tls_wrap:1070:8)
at ssl.onhandshakedone (node:_tls_wrap:856:12) (x5)
解决方案
设置secure:false
server: {
host: "0.0.0.0", // 默认为localhost
port: 3000, // 端口号
open: true, // 是否自动打开浏览器
proxy: {
// 本地开发环境通过代理实现跨域,生产环境使用 nginx 转发
"/api": {
target:"http://192.168.1.1:8000/",
changeOrigin: true,
secure:false // 设为不安全
},
}
}