Skip to content

Instantly share code, notes, and snippets.

@devAgam
Created October 8, 2022 05:45
Show Gist options
  • Save devAgam/815a8bda1968175c4ce6d12fcffa8d1e to your computer and use it in GitHub Desktop.
Save devAgam/815a8bda1968175c4ce6d12fcffa8d1e to your computer and use it in GitHub Desktop.
ENV Url ternary handler
import axios from "axios";
const baseUrlMainServer =
process.env.ENV === "PROD"
? "https://api.project28.in"
: process.env.ENV === "QA"
? "https://qa.project28.in"
: (process.env.ENV = "DEV"
? "https://backend-staging.project28.in"
: "http://localhost:5000");
// const baseUrlMainServer = "http://localhost:5000/api/v1";
export default axios.create({
baseURL: baseUrlMainServer + "/api/v1",
withCredentials: true,
headers: { "Content-Type": "application/json" },
});
export const axiosPrivate = axios.create({
baseURL: baseUrlMainServer + "/api/v1",
headers: { "Content-Type": "application/json" },
withCredentials: true,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment