【发布时间】:2016-09-12 12:44:30
【问题描述】:
我的应用程序在 localhost:8080 上运行,而 node express 在 localhost:8081 上运行。
我的任务是当特定的 url 被点击时说
localhost:8080/autoSearch
这应该由 node express 中间件读取,并在 localhost:8080/logusercheck 上再发出一次请求,如果返回 true,则再次调用以获取结果。
" localhost:8080/logusercheck 如果用户登录则返回真"
为了达到同样的目的
在服务器上安装 xamp 并添加条目为
ProxyPass "/autoSearch" "http://localhost:8081/autolink" ttl=120 ProxyPassReverse /autoSearch http://localhost:8081/autolink
在节点入口点
var express = require('express');
var app = express();
var port = 8081;
var request = require('request');
app.get('/autolink', function (req, res) {
/*Whether user is logged in or not logged --> localhost:8080*/
request('/logusercheck',function(error, response, body){
console.log(response);
console.log(error);
console.log(body);
if (!error && response.statusCode == 200) {
res.send('Searching');
}else{
res.send('you are not logged in');
}
});
});
app.listen(port,function(err,res){
if(err){
console.log('server error');
}else{
console.log('Express Started');
}
});
console.log('server started');
这总是返回“你没有登录”
安慰
reponse undefined
error [Error: Invalid URI "/logusercheck"]
body undefined
我在这里做错了什么。
【问题讨论】:
标签: node.js