How to get "xyz" req.cookie in jwt middleware using Fetch
Unanswered
Holland Lop posted this in #help-forum
Holland LopOP
I have set a cookie in req.cookie when user logs in. This cookie is being received from the client-side through Axios but not on through fetch. How can this be resolved?
I attached 4 screenshots,
1- Setting Cookie in res whenever user logs in
2- Jwt Middleware to authenticate user
3- Frontend Api using fetch
4- two backend consoles, first one is from axios "path: '/api/auth/user'" (I m getting req.cookies here)
second one is from fetch path: '/notifications/user/:page (I m not getting any cookies in req.cookies)
next: 14.0.2
I attached 4 screenshots,
1- Setting Cookie in res whenever user logs in
2- Jwt Middleware to authenticate user
3- Frontend Api using fetch
4- two backend consoles, first one is from axios "path: '/api/auth/user'" (I m getting req.cookies here)
second one is from fetch path: '/notifications/user/:page (I m not getting any cookies in req.cookies)
next: 14.0.2
6 Replies
@Ray did you set the header with axios?
Holland LopOP
nope
@Holland Lop nope
have you tried make a request to /api/auth/user with fetch?
@Ray have you tried make a request to /api/auth/user with fetch?
Holland LopOP
oh, wait lemme check
@Ray
hmm, not sure what happen yet, need to see more code. could you share the repo?