Initial commit
This commit is contained in:
@@ -11,6 +11,7 @@ import axios, {
|
||||
import toast from "react-hot-toast";
|
||||
import { BASE_URL as base } from "@/components/main/BaseUrl";
|
||||
import Cookies from "js-cookie";
|
||||
import { clearAuthSession } from "@/lib/auth/session";
|
||||
|
||||
const BASE_URL = base;
|
||||
const axiosInstance = axios.create({
|
||||
@@ -88,9 +89,14 @@ axiosInstance.interceptors.response.use(
|
||||
);
|
||||
|
||||
const handleUnauthorized = (): void => {
|
||||
if (typeof window !== "undefined") {
|
||||
// toast.error("برای انجام عملیات لطفا وارد حساب کاربری خود شوید");
|
||||
}
|
||||
if (typeof window === "undefined") return;
|
||||
|
||||
const path = window.location.pathname;
|
||||
if (path.startsWith("/login") || path.startsWith("/register")) return;
|
||||
|
||||
clearAuthSession().finally(() => {
|
||||
window.location.href = "/login";
|
||||
});
|
||||
};
|
||||
|
||||
// تایپ اصلاحشده برای درخواستها
|
||||
|
||||
Reference in New Issue
Block a user