File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,25 @@ For more detail, please visit:
6
6
Fullstack with Spring Boot Back-end:
7
7
> [ Spring Boot + Vue.js: Authentication with JWT & Spring Security Example] ( https://bezkoder.com/spring-boot-vue-js-authentication-jwt-spring-security/ )
8
8
9
+ Fullstack with Node.js Express Back-end:
10
+ > [ Node.js Express + Vue.js: JWT Authentication & Authorization example] ( https://bezkoder.com/node-express-vue-jwt-auth/ )
11
+
12
+ ## Note:
13
+ Open ` src/services/auth-header.js ` and modify ` return ` statement for appropriate back-end.
14
+
15
+ ``` js
16
+ export default function authHeader () {
17
+ let user = JSON .parse (localStorage .getItem (' user' ));
18
+
19
+ if (user && user .accessToken ) {
20
+ return { Authorization: ' Bearer ' + user .accessToken }; // for Spring Boot back-end
21
+ // return { 'x-access-token': user.accessToken }; // for Node.js Express back-end
22
+ } else {
23
+ return {};
24
+ }
25
+ }
26
+ ```
27
+
9
28
## Project setup
10
29
```
11
30
npm install
Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ export default function authHeader() {
2
2
let user = JSON . parse ( localStorage . getItem ( 'user' ) ) ;
3
3
4
4
if ( user && user . accessToken ) {
5
- return { Authorization : 'Bearer ' + user . accessToken } ;
5
+ return { Authorization : 'Bearer ' + user . accessToken } ; // for Spring Boot back-end
6
+ // return { 'x-access-token': user.accessToken }; // for Node.js Express back-end
6
7
} else {
7
8
return { } ;
8
9
}
You can’t perform that action at this time.
0 commit comments