【发布时间】:2014-03-26 02:08:14
【问题描述】:
有没有办法检查 nodejs 连接来自哪里?
在 javascript 中我们这样做
if (window.location.host == "localhost")
{
// Do whatever
}
但是我不知道如何在 nodejs 中做,我想做(然后我只需要为 git repo 维护 1 个文件夹)
if (window.location.host == "localhost"){
// connect to localhost mongodb
}else{
// connect to mongodb uri
}
【问题讨论】:
-
你可以检查request IP和server's IP
-
最终使用
require("os")方法,有用的评论
标签: javascript node.js