使用vite + vue3 搭建开发环境 接口请求代理https报错解决方案

17:58:50 [vite] http proxy error at /**/detail?userId=1:
Error: unable to verify the first 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配置写法为

{
   ...
   server: {
          proxy: {
              '/api': {
                  secure: false, // 添加本行内容修复错误
                  target: 'https://**.cn', 
              // }
          }
      }
}

你可能感兴趣的:(vue3vitehttps前端)