[英]Node static serve different index.html for a certain IP address
我正在为一个非常简单的 web 应用程序使用节点 static。
我需要为某个客户端 IP 提供不同的 index.html 服务。
这是我的代码自动取款机:
var fileServer = new(nodeStatic.Server)();
var app = http.createServer(options, function(req, res) {
// Office IP so I dont need code
var staticIp = "111.11.11.11";
var securityCode = "SECRETKEY";
if (staticIp == req.headers['x-real-ip']) {
// TO DO: Server an other index.html
} else if (req.url.includes(securityCode)) {
fileServer.serve(req, res);
} else {
res.writeHead(200, {"Content-Type": "text/plain"});
res.write("Access Denied");
res.end();
}
}).listen(8443);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.