在这里,我在我的节点js服务器127.0.0.1/8081上,如果点击按钮,那么我想切换服务器127.0.0.1/8000

时间:2017-11-17 04:13:10

标签: node.js laravel-5

这里我在我的节点js服务器127.0.0.1/8081上,如果点击按钮,那么我想切换laravel服务器127.0.0.1/8000

if (results.length==0){
    return res.redirect('/alert.html');
}
else{
    return res.redirect('/acess');//from here i want switch server to 127.0.0.1/8000
}

1 个答案:

答案 0 :(得分:0)

您有两个不同的服务器,127.0.0.1:8000127.0.0.1:8081

您正在127.0.0.1:8000上运行nodeJS代码,当您需要重定向到127.0.0.1:8081时,您需要提供完整的URL而不是相对URL。

使用res.redirect('http://127.0.0.1:8000/acess')

您的代码将变为

if (results.length==0){
    return res.redirect('/alert.html');
}
else{
    return res.redirect('http://127.0.0.1:8000/acess');
}