Javascript “提交”按钮未清除express中的cookie

Javascript “提交”按钮未清除express中的cookie,javascript,express,routes,Javascript,Express,Routes,我正在设置一个非常简单的web应用程序。在我的pug文件中,我有以下代码: extends layout.pug block content section#content h2 Welcome, #{name}! form(action='/goodbye', method='post') button(type='submit') Goodbye! footer p An app to help you study 在我的app.js文件中,这是我的代码: app.pos

我正在设置一个非常简单的web应用程序。在我的pug文件中,我有以下代码:

extends layout.pug

block content
section#content
  h2 Welcome, #{name}!
  form(action='/goodbye', method='post')
  button(type='submit') Goodbye!
footer
  p An app to help you study
在我的app.js文件中,这是我的代码:

app.post('/goodbye', (req, res) => {
res.clearCookie('username');
res.redirect('/hello');
});

当我按下提交按钮时,什么也没有发生。不知道为什么会这样。如果您有任何帮助,我们将不胜感激。

您的按钮在表单之外。你得再扣一次才能进去

如果您不想在表单外使用按钮,则必须这样指定:

button(type="submit" form="yourFormId")

好的玩得高兴不要错过将此响应作为已解决的问题
  form(action='/goodbye', method='post')
      button(type='submit') Goodbye!
button(type="submit" form="yourFormId")