I wrote a CoffeeScript code that basically flows as follows:

1, when the client request mode is GET, the output page, the page has a form, form has a Submit button. Form action=””, the default is to submit to itself

2. When the client request mode is POST, the related information is processed

The code file is logout.coffee and looks like this:

module.exports = (req, res) ->
  if req.method is 'GET'
    req.session = null

    template  = 'logout.html'
    return res.render(template, null)

  res.writeHead(303.Location: "/login")
  res.end(a)Copy the code

\

Results in the page, when pressing the submit button, error: cannot submit. Press F12 in browser to check, said 404 error, page can not be found. Action is not specified. Turns out the designation doesn’t work either.

Later, I checked online and woke up to the problem of routing rules:

  app.get ‘/logout’, account.logout

Only get is specified. Add the post

  app.post ‘/logout’, account.logout\

Problem solved. It could also go like this:

  app.all ‘/logout’, account.logout\

Node.js is flexible, compact, and requires a basic understanding of the HTTP protocol. Getting used to Microsoft’S IIS makes you stupid. In The Microsoft system, programmers and ordinary software applications are not much different, using IIS is similar to using Office, which is my sad.

Too late to wake up