From b6be2a8ecb8d8ef074b3256d74f632930f542973 Mon Sep 17 00:00:00 2001 From: aarbit Date: Tue, 30 Sep 2025 00:33:09 -0500 Subject: [PATCH] Adds configurable hostname for multi environments --- .env | 1 + .env.production | 1 + src/App.tsx | 3 ++- src/Config.ts | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .env create mode 100644 .env.production create mode 100644 src/Config.ts diff --git a/.env b/.env new file mode 100644 index 0000000..ca9963a --- /dev/null +++ b/.env @@ -0,0 +1 @@ +VITE_API_URL=http://localhost:8080 \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..30b107c --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +VITE_API_URL=https://tmntapi.halfbinary.net \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index fcb3d31..cbf096e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,12 +1,13 @@ import {useEffect, useState} from 'react' import './App.css' import {Movie} from "./Models.ts"; +import hostName from "./Config.ts"; function App() { const [movies, setMovies] = useState([]) //const [selectedMovie, setSelectedMovie] = useState("") useEffect(() => { - fetch('http://localhost:8080/movies') + fetch(`${hostName}/movies`) .then((response => response.json())) .then((data) => { setMovies(data) diff --git a/src/Config.ts b/src/Config.ts new file mode 100644 index 0000000..557812a --- /dev/null +++ b/src/Config.ts @@ -0,0 +1,2 @@ +const hostName = import.meta.env.VITE_API_URL +export default hostName