index.ts 966 B

123456789101112131415161718192021222324252627282930313233343536
  1. "use client";
  2. import Request from "./axios";
  3. const BASE_URL = process.env.BASE_URL;
  4. console.log(`🎯🎯🎯🎯🎯-> in index.ts on 5`, process);
  5. const server = new Request({
  6. timeout: 10 * 1000,
  7. baseURL: "http://206.168.191.125:8800",
  8. transform: {
  9. // instance interceptor
  10. requestInterceptor: (config) => {
  11. return config;
  12. },
  13. requestInterceptorCatch: (err) => {
  14. return err;
  15. },
  16. responseInterceptor: (config) => {
  17. return config;
  18. },
  19. responseInterceptorCatch: (err) => {
  20. const { response } = err;
  21. if (response && !response.data) return;
  22. // @ts-ignore
  23. const { code } = response!.data;
  24. switch (code) {
  25. case 401:
  26. window && (location.href = "/br/login");
  27. break;
  28. }
  29. return err;
  30. },
  31. },
  32. });
  33. export { server };