header + navigation and menu
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import axios from "axios";
|
||||
import { getToken } from "./func";
|
||||
import { BASE_URL } from "./const";
|
||||
// import { Pages } from "./Pages";
|
||||
|
||||
const axiosInstance = axios.create({
|
||||
// baseURL: process.env.NEXT_PUBLIC_BASE_URL,
|
||||
baseURL: BASE_URL,
|
||||
});
|
||||
|
||||
axiosInstance.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
axiosInstance.interceptors.request.use(async function (config) {
|
||||
const tokenValue = await getToken();
|
||||
const token = tokenValue ? tokenValue : "";
|
||||
|
||||
if (token) {
|
||||
config.headers.Authorization = "Bearer " + token;
|
||||
}
|
||||
return config;
|
||||
});
|
||||
|
||||
export default axiosInstance;
|
||||
@@ -1,2 +1,3 @@
|
||||
export const TOKEN_NAME = "sh_token";
|
||||
export const REFRESH_TOKEN_NAME = "sh_refresh_token";
|
||||
export const BASE_URL = "https://api.shinan.ir";
|
||||
|
||||
Reference in New Issue
Block a user