i dont know why my token keep returning undefined, please help. #5967
Replies: 3 comments
-
One thing. Double check your cross origin configuration: Add Or use the |
Beta Was this translation helpful? Give feedback.
-
Install package cors import it in your main file While generating token during login and sign-up send the token in header response because in your JWT Auth you are trying to receive from header . Other means : You may try sending token via cookies in that case install cookie-parser and add it's Middleware. Then it has functions like res.cookie and in your JWT Auth you can simple receive it by req.cookie.token . |
Beta Was this translation helpful? Give feedback.
-
In which route you are saving token to your local Storage? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
So im trying to secure an endpoint that allows user create blog, so anyone wont just go over to the '/blogPublish' and have access to it but i keep getting faced with an error when i try to access it... ILL BE GLAD IF ANYONE CAN HELP
server.js
./routes/protect.route.js
authMiddleware
and in my publishBlog.html script:
BUT I JUST KEEP GETTING THIS ERROR ON MY TERMINAL, EVEN THO I HAVE AN AUTH Token saved on my local storage authToken | eyJhbGciOiJIUzI1NiIsInR5c:
Beta Was this translation helpful? Give feedback.
All reactions