For instruction, please visit:
Vue 3 Authentication & Authorization with JWT, Vuex and Vue Router
Open src/services/setupInterceptors.js
and modify config.headers
for appropriate back-end (found in the tutorial).
instance.interceptors.request.use(
(config) => {
const token = TokenService.getLocalAccessToken();
if (token) {
// config.headers["Authorization"] = 'Bearer ' + token; // for Spring Boot back-end
config.headers["x-access-token"] = token; // for Node.js Express back-end
}
return config;
},
(error) => {
return Promise.reject(error);
}
);
Related Posts:
Fullstack with Spring Boot Back-end:
Spring Boot + Vue.js: Authentication with JWT & Spring Security Example
Fullstack with Node.js Express Back-end:
Node.js Express + Vue.js: JWT Authentication & Authorization example
Fullstack CRUD:
Integration (run on same server/port):
npm install
npm run serve
npm run build
npm run lint