add
This commit is contained in:
parent
82048a115e
commit
8652488bad
|
@ -1,20 +1,20 @@
|
|||
import axios from 'axios';
|
||||
import { env } from '../env';
|
||||
const BASE_URL = `http://${env.SERVER_IP}:3000`
|
||||
import axios from "axios";
|
||||
import { env } from "../env";
|
||||
const BASE_URL = `http://${env.SERVER_IP}:${env.SERVER_PORT}`;
|
||||
const apiClient = axios.create({
|
||||
baseURL: BASE_URL,
|
||||
// withCredentials: true,
|
||||
baseURL: BASE_URL,
|
||||
// withCredentials: true,
|
||||
});
|
||||
// Add a request interceptor to attach the access token
|
||||
apiClient.interceptors.request.use(
|
||||
(config) => {
|
||||
const accessToken = localStorage.getItem('access_token');
|
||||
if (accessToken) {
|
||||
config.headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error) => Promise.reject(error)
|
||||
(config) => {
|
||||
const accessToken = localStorage.getItem("access_token");
|
||||
if (accessToken) {
|
||||
config.headers["Authorization"] = `Bearer ${accessToken}`;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error) => Promise.reject(error)
|
||||
);
|
||||
|
||||
export default apiClient;
|
||||
|
|
Loading…
Reference in New Issue