-
JWT TOKEN STRUCTURE
jwt_token = xyz.abc.uvw
Where,
- xyx = header
- abc = payload
- uvw = secretkey
-
Jwt methods
jwt.sign() // creates a token jwt.decode() //decodes the payload only without the help of signature jwt.verify() //decodes the token with the help of signature
-
HTTPOnly
setting HttpOnly : true, allows the use of localStorage.getItem("jwt") but makes the site more vulnerable (XSS attacks)
-
React custom hook names
Always use "use" in a custom hook name since the hook uses existing react hooks eg :
function useFunctionName(){ // code }
-
Status Codes
- 302 : found
- 200 : OK
- 201 : Created
- 204 : No content
- 400 : Bad Request
- 401 : Unauthorized
- 404 : Not found
- 403 : Forbidden
- 500 : Internal Server Error
- 502 : Bad Gateway
- 503 : Service Unavailable
-
withCredentials Always set withCredentials: true in you axios or fetch request when it includes cors or cookies(jwt)