Nodejs Fetch API:无法验证第一个证书

Nat*_*han 4 http fetch node.js philips-hue

我在我的 Philips Hue 项目中使用 fetch API 模块,当我调用本地 IP 地址(我的集线器)时,它会在标题中产生该错误。

const fetch = require('node-fetch');
const gateway = "192.168.0.12";
const username = "username";

let getLights = function(){
    fetch(`https://${gateway}/api/${username}/lights`, {
        method: 'GET'
    }).then((res) => {
        return res.json();
    }).then((json) => {
        console.log(json);
    });
}


module.exports = {getLights};
Run Code Online (Sandbox Code Playgroud)

任何安全的解决方案最终都会进入公共互联网,让我可以从任何地方访问我的灯吗?

yPh*_*hil 9

要跳过 SSL 测试,您可以使用以下命令:

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;