我使用了npm软件包网站中express-ntlm的提供示例 当我仅使用浏览器时,它可以正常工作,但是当我将其与react app一起使用时,出现错误504或401错误(已修复)
在http://localhost:3553/getAuthenticate上运行的应用
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Request-Method", "POST,GET,*");
next();
});
app.use(ntlm({
debug: function() {
var args = Array.prototype.slice.apply(arguments);
console.log.apply(null, args);
},
domain: 'bridgebankgroup.com',
domaincontroller: 'ldap://mydomaine.com:389',
}));
app.all('/getAuthenticate', function(request, response,next) {
stringParam=request.ntlm.UserName;
console.log(request);
response.send({resp:stringParam});
next(err,{
function(){response.send({resp:stringParam})}
})
componentDidMount(){
fetch('/getAuthenticate',
{
method: 'GET',
headers:
{
'Content-Type': 'application/json',
}
},
).then(res => res)
.then(
(result) => {
console.log(result)
},
(error) => {
console.log(error.status);
});
}
./src/setupProxy.js中的代理配置
module.exports = function(app) {
app.use('/getAuthenticate', proxy({
target: 'http://localhost:3553/',
changeOrigin: true,
}));
};
我想调用此应用以了解用户使用我的应用