文章内容
2019/4/5 15:36:29,作 者: 黄兵
ERR_TLS_CERT_ALTNAME_INVALID
最近在使用Angular proxy的时候,出现了如下错误:
[HPM] Error occurred while trying to proxy request /api/v1.0/values from localhost:4200 to https://www.pdflibr.com (ERR_TLS_CERT_ALTNAME_INVALID) (https://nodejs.org/api/errors.html#errors_common_system_errors)
出现这个错误的的原因是:
使用TLS时,对等方的主机名/ IP subjectAltNames与其证书中的任何主机名/ IP都不匹配 。
解决方案:
在proxy.config.json中设置:
{ "/api": { "target": "https://www.pdflibr.com", "changeOrigin": true } }
相比HTTP的方式,需要额外添加 changeOrigin:true
参考资料:
1、ERR_TLS_CERT_ALTNAME_INVALID
2、Angular Cli Proxy to HTTPS Server Angular 转发至 HTTPS server
黄兵个人博客原创。
评论列表