Skip to content

Commit

Permalink
feat: ⚡ store all urls used in an object
Browse files Browse the repository at this point in the history
  • Loading branch information
Naresh-Khatri committed Jun 30, 2024
1 parent 68f95d7 commit 3b86b35
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/axios.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 3b86b35

Please sign in to comment.