解决vite代理访问后台接口出现 Error: self-signed certificate
错误信息:press h + enter to show help 15:33:47 [vite] http proxy error: /api/user/auth/loginCheck Error: self-signed certificate at TLSSocket.onConnectSecure (node:_tls_wrap:1550:34) at TLSSocket.emit (node:events:514:28) at TLSSocket._finishInit (node:_tls_wrap:967:8) at ssl.onhandshakedone (node:_tls_wrap:743:12)
原因:Vite 开发代理请求到后端 API 时,后端用了自签名证书 (self-signed certificate),Node.js 默认不信任,导致 HTTPS 握手失败。
解决方案:在vite.config.js的配置中添加secure: false