Django login_required redirect to login page even when user is authenticated

I setup login_required in my app to limit access to pages to logged users. It works fine locally, if user is authenticated, he has access to the page and if not, he will be asked to enter his credentials. The problem is, in production, even when the user is authenticated, he will be redirected to the login page. Any idea how can I resolve this issue ? Thanks!

I removed login_required and tried the raw way which is using the if statement if not request.user.is_authenticated: return redirect(f"{settings.LOGIN_URL}?next={request.path}")

But I still have the same issue.

I need the user once logged into the app to be able to go to other pages without asking for login again as it works locally.

Back to Top