This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DB_CLIENT=mysql | |
DB_PORT=3306 | |
DB_HOST=127.0.0.1 | |
DB_NAME=nextfullstack | |
DB_USER= | |
DB_PASS= | |
BASE_URL=http://localhost:3000/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function jwtDecode(token: any) { | |
const base64Urls = token.split('.'); | |
base64Urls.map( (url: string, i: number) => { | |
if(i<2) | |
base64Urls[i].replace(/-/g, '+').replace(/_/g, '/'); | |
}); | |
const jwtHeader = JSON.parse(Buffer.from(base64Urls[0], 'base64').toString()); | |
const jwtPayload = JSON.parse(Buffer.from(base64Urls[1], 'base64').toString()); |