I am trying to check the user is logged in or not, so i am sending a get request to drf and i am using axios to fetch it, i followed a tutorial but it doesn't works, screenshot has Error, react.ts axios usage, drf view for it, i put corsheader in installed app and added it into middleware as well, i also added the react link in cors allowed host
class UserView(APIView):
permission_classes = (permissions.IsAuthenticated, )
authentication_classes = (SessionAuthentication, )
def get(self, request):
serializer = UserSerializer(request.user)
return Response({"user": serializer.data}, status=status.HTTP_200_OK)```
**urls.py**
```urlpatterns = [
path("api/botpanel/register/", UserRegister.as_view(), name="bot_panel_register_user"),
path("api/botpanel/login/", UserLogin.as_view(), name="bot_panel_login_user"),
path("api/botpanel/logout/", UserLogout.as_view(), name="bot_panel_logout_user"),
path("api/botpanel/user/", UserView.as_view(), name="bot_panel_user"),
]```
**Settings.py**
```CORS_ALLOWED_ORIGINS = [
'http://localhost:5173', # Add the origin of your React app
]
# Optional: Allow credentials (cookies, authorization headers, etc.) to be sent
CORS_ALLOW_CREDENTIALS = True
CORS_TRUSTED_ORIGINS = [
'http://localhost:5173', # Add the origin of your React app
]
CSRF_COOKIE_HTTPONLY = False
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'```