Created
November 9, 2020 06:25
-
-
Save blogcacanid/8cc1040f86c7dba430b0d829deb10f6e to your computer and use it in GitHub Desktop.
auth-header.js Authentication JWT Vue Lumen 7
This file contains hidden or 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 authHeader() { | |
let user = JSON.parse(localStorage.getItem('user')); | |
if (user && user.accessToken) { | |
// for Lumen 7 back-end | |
return { Authorization: 'Bearer ' + user.accessToken }; | |
// for Node.js Express back-end | |
// return { 'x-access-token': user.accessToken }; | |
} else { | |
return {}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment