我在Philips Hue项目中使用了访存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};
任何SECURE修复程序最终都会进入公共互联网,让我可以从任何地方访问灯吗?
答案 0 :(得分:1)
似乎您尝试使用HTTPS访问它。在您的本地网络上最有可能是HTTP
因此,将https://${gateway}/api/${username}/lights
更改为http://${gateway}/api/${username}/lights
应该可以。
如果您尝试将其保留为HTTPS,则必须在网络上安装SSL证书颁发机构。
如果您想完成这些工作,这些可能是有用的资源:
答案 1 :(得分:0)
要跳过 SSL 测试,您可以使用:
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;