From 98320b6fdd84733f6d4e8ffdad415f95cdbbd311 Mon Sep 17 00:00:00 2001 From: JBB0807 <104856796+JBB0807@users.noreply.github.com> Date: Mon, 5 May 2025 19:03:02 -0700 Subject: [PATCH] change harcoded URL to .env/secrets --- .env | 4 ++-- .env.development | 2 +- src/pages/AssignmentPage.jsx | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.env b/.env index ddf3a43..827b820 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -#VITE_AUTH_URL="http://localhost:8080" -VITE_AUTH_URL="https://byte-camp-auth-service.fly.dev" \ No newline at end of file +VITE_AUTH_URL="https://byte-camp-auth-service.fly.dev" +VITE_ASSIGNMENT_URL="https://assignment-service.internal" \ No newline at end of file diff --git a/.env.development b/.env.development index 7dc9c2c..7affb16 100644 --- a/.env.development +++ b/.env.development @@ -1,2 +1,2 @@ VITE_AUTH_URL="http://localhost:8080" -#VITE_AUTH_URL="https://byte-camp-auth-service.fly.dev" \ No newline at end of file +VITE_ASSIGNMENT_URL="http://localhost:8082" \ No newline at end of file diff --git a/src/pages/AssignmentPage.jsx b/src/pages/AssignmentPage.jsx index 985ff15..ba560b7 100644 --- a/src/pages/AssignmentPage.jsx +++ b/src/pages/AssignmentPage.jsx @@ -15,6 +15,8 @@ const AssignmentPage = () => { const [showModal, setShowModal] = useState(false); const [editingIndex, setEditingIndex] = useState(null); + const VITE_ASSIGNMENT_URL = import.meta.env.VITE_ASSIGNMENT_URL; + useEffect(() => { document.title = "Assignment"; fetchAssignments(); @@ -22,7 +24,7 @@ const AssignmentPage = () => { const fetchAssignments = async () => { try { - const res = await fetch("http://localhost:8082/instructor/list/9", { + const res = await fetch(`${VITE_ASSIGNMENT_URL}/instructor/list/9`, { // credentials: "include", }); if (!res.ok) throw new Error("Failed to fetch"); @@ -80,7 +82,7 @@ const AssignmentPage = () => { formData.append("file", file, file.name); } - fetch("http://localhost:8082/instructor/create", { + fetch(`${VITE_ASSIGNMENT_URL}/instructor/create`, { method: "POST", body: formData, })