From 5f1b0bb1883a8021c7261dad59e063824849fd81 Mon Sep 17 00:00:00 2001 From: realtradam Date: Wed, 22 May 2024 19:05:07 -0400 Subject: add prod/dev env vars --- src/components/Blogs.jsx | 2 +- src/components/Game.jsx | 4 ++-- src/components/GameCard.jsx | 6 +++--- src/components/Games.jsx | 6 +++--- src/components/Home.jsx | 6 +++--- src/components/Layout.jsx | 11 ----------- 6 files changed, 12 insertions(+), 23 deletions(-) (limited to 'src/components') diff --git a/src/components/Blogs.jsx b/src/components/Blogs.jsx index f52f286..2dc8f27 100644 --- a/src/components/Blogs.jsx +++ b/src/components/Blogs.jsx @@ -6,7 +6,7 @@ const Blogs = () => { const [blogs, setBlogs] = useState([]); useEffect(() => { - const url = "/api/v1/blogs/index"; + const url = `${import.meta.env.VITE_API_TITLE}/api/v1/blogs/index`; fetch(url).then((response) => { if (response.ok) { return response.json(); diff --git a/src/components/Game.jsx b/src/components/Game.jsx index 8b80b8e..7746767 100644 --- a/src/components/Game.jsx +++ b/src/components/Game.jsx @@ -9,13 +9,13 @@ import Button from "./Button"; //export default () => ( export default function Games () { let { user, game } = useParams(); -//http://localhost:3000/api/v1/game/realtradam/orc-arena-of-time/index.html +//http://%{VITE_API_TITLE}/api/v1/game/realtradam/orc-arena-of-time/index.html return( <>
Orc: Arena of Time
- +
diff --git a/src/components/GameCard.jsx b/src/components/GameCard.jsx index 9cd815d..82ad423 100644 --- a/src/components/GameCard.jsx +++ b/src/components/GameCard.jsx @@ -15,10 +15,10 @@ export default function GameCard ({ link = "./", width = "72", game = { card_img
- +
- - + +
diff --git a/src/components/Games.jsx b/src/components/Games.jsx index f1545b8..a0646be 100644 --- a/src/components/Games.jsx +++ b/src/components/Games.jsx @@ -7,13 +7,13 @@ import Button from "./Button"; export default function Games () { const [games, setGames] = useState([]); useEffect(() => { - const url = "/api/v1/games"; + const url = `${import.meta.env.VITE_API_TITLE}/api/v1/games`; fetch(url).then((response) => { if (response.ok) { return response.json(); } throw new Error("Network response was not ok."); - }).then((response) => setGames(response)).catch(() => navigate("/")); + }).then((response) => setGames(response))//.catch(() => navigate("/")); }, []); const allGames = games.map((game) => ( @@ -35,7 +35,7 @@ export default function Games () { console.log(pair[0] + ', ' + pair[1]) }; - fetch('http://127.0.0.1:3000/api/v1/games', { + fetch('${import.meta.env.VITE_API_TITLE}/api/v1/games', { method: 'post', body: formData, }); diff --git a/src/components/Home.jsx b/src/components/Home.jsx index 863d81d..c1fb689 100644 --- a/src/components/Home.jsx +++ b/src/components/Home.jsx @@ -15,7 +15,7 @@ export default function Home () { console.log(pair[0] + ', ' + pair[1]) }; - fetch('http://127.0.0.1:3000/api/v1/games', { + fetch('${import.meta.env.VITE_API_TITLE}/api/v1/games', { method: 'post', body: formData, }); @@ -24,11 +24,11 @@ export default function Home () { <>
-
Get To Know Me a Little
+
Work In Progress
-

Debug! Again

+

API at: { import.meta.env.VITE_API_TITLE }

Ea optio vitae culpa voluptatem consectetur. Ab quisquam sed ipsum. Perspiciatis minus odit quas qui consequuntur dicta reiciendis a. Nihil minima sed aliquam.

diff --git a/src/components/Layout.jsx b/src/components/Layout.jsx index 9aac935..06df03a 100644 --- a/src/components/Layout.jsx +++ b/src/components/Layout.jsx @@ -6,17 +6,6 @@ export default function Layout ({userData}) console.log(userData); //const [userData, setUserData] = useState({ name: "" }); - // if the user tries to access the isolated domain then we redirect them - // this is NOT done for security, only for good UX - // rails serves the react app no matter what - // so the app would be broken when served on the isolated domain - const domain = window.location.host; - console.log(domain); - //if(domain === "localhost:3000") - //{ - // window.location.replace("http://127.0.0.1:3000"); - //} - return ( <>
-- cgit v1.2.3