fosrl.pangolin/src/api/index.ts

26 lines
572 B
TypeScript
Raw Normal View History

2024-10-06 12:39:05 -04:00
import axios from "axios";
2024-10-26 17:13:30 -04:00
let origin;
if (typeof window !== "undefined") {
origin = window.location.origin;
}
2024-10-26 17:01:34 -04:00
2024-10-06 12:39:05 -04:00
export const api = axios.create({
2024-10-26 17:13:30 -04:00
baseURL: `${origin}/api/v1`,
2024-10-06 22:09:30 -04:00
timeout: 10000,
headers: {
"Content-Type": "application/json",
},
});
2024-10-26 17:13:30 -04:00
// we can pull from env var here becuase it is only used in the server
2024-10-06 22:09:30 -04:00
export const internal = axios.create({
2024-10-26 17:13:30 -04:00
baseURL: `http://localhost:${process.env.SERVER_EXTERNAL_PORT}/api/v1`,
2024-10-06 12:39:05 -04:00
timeout: 10000,
headers: {
"Content-Type": "application/json",
},
});
export default api;