简体   繁体   English

节点basic-auth-在URL中传递基本身份验证凭据不起作用

[英]node basic-auth - pass basic authentication credentials in URL not working

I have tried http://admin:admin@localhost:8066/admin/ but it didnt work. 我已经尝试过http:// admin:admin @ localhost:8066 / admin /,但是没有用。 In previous projects, it worked, I wonder if any mistakes I made? 在以前的项目中,它奏效了,我想知道我是否犯了任何错误?

module.exports = function (request, response, next) {
  var user = auth(request);
  if (!user || !config_credential[user.name] || config_credential[user.name].password !== user.pass) { 
    response.set('WWW-Authenticate', 'Basic realm="Authorization Required"');
    return response.status(401).send();
  }
    return next();
};

And added the middleware. 并添加了中间件。

app.use("/admin", auth, xxxx );

ps. PS。 is using node basic-auth 正在使用节点basic-auth

The reason I want to do is to run the admin cron jobs in server. 我想做的原因是在服务器中运行admin cron作业。

发现如果我更改了主机表,它最终可以在不使用localhost的情况下工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM