【发布时间】:2021-10-08 14:45:51
【问题描述】:
我正在开发一个网络应用程序,用户可以在其中填写他们的联系方式并提交表单。提交后,我将它们重定向到/failure 或/success where
app.get("/success", function(req, res) {
res.sendFile(__dirname + "/success.html");
});
app.get("/failure", function(req, res) {
res.sendFile(__dirname + "/failure.html");
});
但是,用户也可以访问/failure 和/success,如果他们只需在url 的路径中输入这些。我怎样才能防止这种情况?我只希望在提交表单后显示失败/成功页面。
【问题讨论】:
-
在标题或帖子正文中设置一些内容(作为隐藏参数)并在两条路线中读取它,即
/success&/failure
标签: node.js express web-applications