[英]TypeError: object is not a function Node js Node Authentication
[英]Node.js Authentication TypeError: object is not a function
我目前正在学习如何在Node.js中构建一个简单的HTTP身份验证系统的教程 。 我已经按照教程中的所有步骤进行了操作,但是当我尝试运行它时,我总是得到这个错误: TypeError: object is not a function
这是教程中的代码:(错误发生在第3行)
var http = require("http");
var auth = require("http-auth");
var digest = auth({
authRealm: "Private area",
authFile: __dirname + "/htpasswd",
authType: "digest"
});
var server = http.createServer(function(request, response) {
digest.apply(request, response, function(username) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello " + username);
response.end();
});
});
server.listen(80);
console.log("Server is listening");
提前致谢! 对不起,如果这个问题非常愚蠢,我是Node.js的新手。 :P
尝试使用:
var basic = auth.basic({
authRealm: "Private area",
authFile: __dirname + "/htpasswd",
authType: "digest"
});
用于分配basic
变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.