【发布时间】:2020-03-05 11:36:57
【问题描述】:
文件夹是这样设置的
-公开
-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") 工作,但没有别的。就像它只是忽略我给它的任何类型的重定向命令。
感谢您的帮助。
【问题讨论】:
标签: javascript node.js express redirect routing