Untitled

mail@pastecode.io avatar
unknown
javascript
a year ago
667 B
3
Indexable
Never
import axios from "axios";

axios.defaults.headers.post["Content-Type"] = "multipart/form-data";

const customAxios = axios.create({
  baseURL:
    process.env.NODE_ENV === "development"
      ? "/"
      : "https://8000-ujuniordev-drftaskmanag-kgh15g7wk58.ws-us104.gitpod.io/",
});

customAxios.withCredentials = true;

customAxios.interceptors.response.use(
  (response) => {
    return response;
  },
  (error) => {
    switch (error.response.status) {
      case 401 || 403:
        localStorage.clear("tmng-user");
        window.location = "/signin";
        break;

      default:
        return Promise.reject(error);
    }
  }
);

export default customAxios;