I am a beginner using jsonwebtoken to authenticate a user in my node.js web app. I signed a jwt token in app.post('/login') using jwt.sign() and when i try to access/ verify it in app.get('/dashboard') using req.headers['authorization'].split(' ').[1] it gives null or undefined as there is no authorization header in console.log(req.headers).
But it can be access or verify in postman as there i set auth type to bearer <token> due to which number of headers increment by 1 that is authorization: bearer <token>.
Then i store the token in cookie using res.cookie('token', accessToken) and i can access it in my routes without postman.
keeping in view above scenario i have following confusions:
- Where else can i store
jwt tokento access in my browser? and which is most secure store to accessjwt tokenin browser? - Why there is no
authorization: bearer <token>header in my browser?? - Can i add
authorization: bearer <token>header manually to access the token in my browser? if yes...how? - If my app use
httpsinsteadhttpprotocol then will it be same situation of noauthorization: bearer <token>header in browser?
I googled it but cant conclude. please help....!
