I
I
iredoff2020-09-07 12:07:56
JavaScript
iredoff, 2020-09-07 12:07:56

Why is "localhost redirected too many times"?

Hello, I decided to write a site where you need to have an admin panel of the site. But here's the problem, everything was fine until it came to checks for having cookies. On swag, I found a piece of code that checks all incoming requests. That is, if there are cookies, then the next() function is called , and if there are none, then a redirect to the page with authorization. But for some reason, redirection does not work if you go to the address "/admin/..", "/admin/settings/" - for example.

Code:
5f55f82ab9e0a984664300.png
5f55f837b0b7d299790858.png

Could you explain what the problem is and tell more about its solution? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2020-09-07
@Robur

The user comes to admin/login to register. And there your piece of code works, it looks to see if there are cookies, there are no cookies, so we send the user to admin/login. The user goes to admin/login to register. And there your piece of code works, it looks to see if there are cookies, there are no cookies, so we send the user to admin/login. The user goes to admin/login to register. And there your piece of code works, it looks to see if there are cookies, there are no cookies, so we send the user to admin/login. The user goes to admin/login to register. And there your piece of code works, it looks to see if there are cookies, there are no cookies, so we send the user to admin/login. User comes to admin/login ....
.... time passes ...
the browser gets bored with all this and stops this fun process.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question