Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@blogcacanid
Created November 11, 2020 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blogcacanid/b05c9052259d579e8eb1a23578e7c953 to your computer and use it in GitHub Desktop.
Save blogcacanid/b05c9052259d579e8eb1a23578e7c953 to your computer and use it in GitHub Desktop.
auth-header.js Authentication JWT React JS Lumen 7
export default function authHeader() {
const 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