文件夹设置如下
-公共
-landing
-landing.html
-Login
-login.html
-register
-register.html
-路线
-HTMLroutes
-APIroutes
-server.js
所有被注释掉的东西都是我尝试过的没有成功的事情
if(bcrypt.compare(req.body.user.password,user.Password)){
console.log("successful login")
// res.send({redirect: '/app'})
// res.redirect("app")
// return res.redirect("/app")
// res.sendFile(path.join("./public/landing/landing.html"))
// res.sendFile('./landing/landing.html',{ root: "public" })
}
landing.html是我希望用户看到的页面。是通过将路由重定向到“ / app”之类的内容还是通过加载页面来加载它。
“ res.sendFile(path.join ...)”是我最喜欢的,但是我的错误是文件路径不是“绝对”
在我的server.js中,我使用express.static(“ public”),我知道它起了某种作用
但是每次我测试时,console.log(“ successful login”)都可以正常工作,但是没有别的。就像它只是忽略了我给它的任何类型的重定向命令。
感谢您的帮助。