#Having trouble getting user information from the backend

2 messages · Page 1 of 1 (latest)

reef kernel
#

Hello everyone, I'm new so I haven't learned much about nuxt so I'm having some problems.
I used ExpressJs to initialize the api, in the /profile route I authenticated by decoding the token from the cookie.
As for the frontend, I use nuxt to login and register. When I log in, I use useCookie to save the token. I don't know if my solution works or not: I send cookies from the frontend to the backend this way. That is, when using the POST method from login, a cookie is sent. const res = await $fetch<User>('http://localhost:8090/api/v1/login/', { method: "POST", body: data, withCredentials: true, });
but after logging in and redirecting to /profile it gives an error:
GET : URL (401 (Unauthorized))
I'm thinking that the backend can't read the cookies from the frontend, so an error occurs.
Can you help me, or can anyone who has done projects on Express and NUXT give me directions?
Thanks you!

grizzled stag