source: jobvista-frontend/src/axios/axiosInstance.js@ 4d97b63

main
Last change on this file since 4d97b63 was d8b6c91, checked in by 223021 <daniel.ilievski.2@…>, 6 months ago

Initial commit - implementirano registracija i logiranje so Spring Security i JSON Web Token-i vo backend-ot kako i navbar i formi za istoto vo frontend-ot

  • Property mode set to 100644
File size: 521 bytes
Line 
1import axios from "axios";
2export const AUTH_TOKEN = 'AUTH_TOKEN';
3
4const axiosInstance = axios.create({
5 baseURL: 'http://localhost:8080'+'/api',
6 headers: {
7 'Access-Control-Allow-Origin': '*'
8 }
9})
10
11axiosInstance.interceptors.request.use(
12 config => {
13 const token = localStorage.getItem(AUTH_TOKEN);
14 if (token) {
15 config.headers.Authorization = `Bearer ${token}`;
16 }
17 return config;
18 },
19 error => Promise.reject(error)
20);
21
22export default axiosInstance;
Note: See TracBrowser for help on using the repository browser.