Login problems encountered cookie

First do with express service side, experiencing login cookie problem set, sort out what is probably such a process:

Frontend user name, password after submitting, backstage look at the database records to find records returned code = 0 login is successful, while the back is written the cookie .

In express project app.js written to the file in a middleware, with app.use (), means that any one of GET , POST requests should take this step filtration moment, this function comes REQ , RES , the Next three parameters after printing after discovery cookie in the header , the front desk when so requested interface, where you can determine there is no cookie , no words to redirect jump login page.

Since all interfaces have to take this step, include / login this page, so there are a redirect too many times leads to a page Ben collapse. Then add the judgment, the path url if login not jump. The results Login not successful, then found logon interface is a login / in , but also to meet the url not login conditions, the result was intercepted jump back to the login page request, Montreal pit ah!

Because management background is a vue to do, from a separate service, and express another service, development time is not yet packaged into the next express service, so brush back a page appeared " Error: of Can They are not the After the SET headers Sent. ", says Baidu is due to redirect repeated written request of the head, was found later packaged accessed in the same service, there is no such problem, I will not tangle, and finally released after all, is to put together of.



Guess you like

Origin blog.51cto.com/14430893/2417151