source: frontend/src/api/axios.js@ 3ebe47c

Last change on this file since 3ebe47c was 3ebe47c, checked in by Andrej <asumanovski@…>, 5 months ago

Made authentication on frontend and backend

  • Property mode set to 100644
File size: 388 bytes
Line 
1import axios from "axios";
2
3const api = axios.create({
4 baseURL: import.meta.env.VITE_API_BASE_URL ?? "http://localhost:8080/api",
5});
6
7api.interceptors.request.use((config) => {
8 const token = localStorage.getItem("authToken");
9 if (token) {
10 config.headers = config.headers ?? {};
11 config.headers.Authorization = `Bearer ${token}`;
12 }
13 return config;
14});
15
16export default api;
Note: See TracBrowser for help on using the repository browser.