这里我在我的节点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
}
答案 0 :(得分:0)
您有两个不同的服务器,127.0.0.1:8000
和127.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');
}