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