From 3b86b352a29d0aa335440bf3f58375a908fe07bb Mon Sep 17 00:00:00 2001 From: naresh-khatri Date: Sun, 30 Jun 2024 11:01:48 +0530 Subject: [PATCH] feat: :zap: store all urls used in an object --- lib/axios.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/axios.ts b/lib/axios.ts index 4551a54..1dc5729 100755 --- a/lib/axios.ts +++ b/lib/axios.ts @@ -1,17 +1,20 @@ import axios from "axios"; import { auth } from "../firebase/firebase"; +const urls = { + local: "http://localhost:3333", + tunnel: "https://dev3333.codingducks.xyz", + prod: "https://api2.codingducks.xyz", + local_network: "http://192.168.31.197:3333", +}; export const baseURL = - process.env.NODE_ENV === "development" - ? "http://localhost:3333" - : // ? "https://dev3333.codingducks.xyz" - // "http://192.168.31.197:3333" - "https://api2.codingducks.xyz"; + process.env.NODE_ENV == "development" ? urls.local : urls.prod; const axiosInstance = axios.create({ baseURL, transformResponse: [ (response) => { + // parse JSON response const res = JSON.parse(response); if (res.code == 401 && typeof window !== "undefined") { window.location.href = "/login?from=" + window.location.pathname;