From 68868be7ed602a1811ae495fca6038726c6964d7 Mon Sep 17 00:00:00 2001 From: Jane Kamata Date: Sun, 30 Mar 2025 18:13:07 -0400 Subject: [PATCH 1/3] Masked urls with environment variable for localhost:3001 --- frontend/src/Bell.tsx | 2 +- frontend/src/Profile.tsx | 2 +- frontend/src/Register.tsx | 4 ++-- frontend/src/context/auth/authContext.tsx | 4 ++-- frontend/src/grant-info/components/GrantItem.tsx | 2 +- frontend/src/grant-info/components/GrantList.tsx | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/src/Bell.tsx b/frontend/src/Bell.tsx index 8b40e0c..afb605c 100644 --- a/frontend/src/Bell.tsx +++ b/frontend/src/Bell.tsx @@ -21,7 +21,7 @@ const BellButton = () => { // function that handles when button is clicked and fetches notifications const handleClick = async () => { const response = await fetch( - `http://localhost:3001/notifications/user/${currUserID}`, + `${import.meta.env.VITE_SERVER_URL}/notifications/user/${currUserID}`, { method: "GET", } diff --git a/frontend/src/Profile.tsx b/frontend/src/Profile.tsx index f6c545e..f3d9f0e 100644 --- a/frontend/src/Profile.tsx +++ b/frontend/src/Profile.tsx @@ -19,7 +19,7 @@ const Profile = observer(() => { e.preventDefault(); try { - const response = await fetch("http://localhost:3001/auth/update-profile", { + const response = await fetch(import.meta.env.VITE_SERVER_URL+"/auth/update-profile", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/frontend/src/Register.tsx b/frontend/src/Register.tsx index 32bd798..14ad1c8 100644 --- a/frontend/src/Register.tsx +++ b/frontend/src/Register.tsx @@ -16,7 +16,7 @@ const Register = observer(() => { e.preventDefault(); try { - const response = await fetch("http://localhost:3001/auth/register", { + const response = await fetch(import.meta.env.VITE_SERVER_URL+"/auth/register", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ username, password, email }), @@ -30,7 +30,7 @@ const Register = observer(() => { } // If registration succeeded, automatically log in the user - const loginResponse = await fetch("http://localhost:3001/auth/login", { + const loginResponse = await fetch(import.meta.env.VITE_SERVER_URL+"/auth/login", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ username, password }), diff --git a/frontend/src/context/auth/authContext.tsx b/frontend/src/context/auth/authContext.tsx index 4ef4bde..7825f0d 100644 --- a/frontend/src/context/auth/authContext.tsx +++ b/frontend/src/context/auth/authContext.tsx @@ -33,7 +33,7 @@ export const AuthProvider = observer(({ children }: { children: ReactNode }) => * Attempt to log in the user */ const login = async (username: string, password: string) => { - const response = await fetch('http://localhost:3001/auth/login', { + const response = await fetch(import.meta.env.VITE_SERVER_URL+'/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username, password }), @@ -54,7 +54,7 @@ export const AuthProvider = observer(({ children }: { children: ReactNode }) => * Register a new user and automatically log them in */ const register = async (username: string, password: string, email: string) => { - const response = await fetch('http://localhost:3001/auth/register', { + const response = await fetch(import.meta.env.VITE_SERVER_URL+'/auth/register', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username, password, email }), diff --git a/frontend/src/grant-info/components/GrantItem.tsx b/frontend/src/grant-info/components/GrantItem.tsx index 1ea8ad6..ae52126 100644 --- a/frontend/src/grant-info/components/GrantItem.tsx +++ b/frontend/src/grant-info/components/GrantItem.tsx @@ -37,7 +37,7 @@ const GrantItem: React.FC = ({ grant }) => { try { console.log("Saving grant!"); console.log(curGrant); - const response = await fetch("http://localhost:3001/grant/save", { + const response = await fetch(import.meta.env.VITE_SERVER_URL+"/grant/save", { method: "PUT", headers: { "Content-Type": "application/json", diff --git a/frontend/src/grant-info/components/GrantList.tsx b/frontend/src/grant-info/components/GrantList.tsx index c05fd3b..fd3c0e7 100644 --- a/frontend/src/grant-info/components/GrantList.tsx +++ b/frontend/src/grant-info/components/GrantList.tsx @@ -19,7 +19,7 @@ import { Grant } from "../../../../middle-layer/types/Grant.ts"; // How many items to show per page const fetchGrants = async () => { try { - const response = await fetch("http://localhost:3001/grant"); + const response = await fetch(import.meta.env.VITE_SERVER_URL + "/grant"); if (!response.ok) { throw new Error(`HTTP Error, Status: ${response.status}`); } From dd2672cb1a81f6c4bbfcbdb97ae358bc85be473b Mon Sep 17 00:00:00 2001 From: Jane Kamata <38163243+janekamata@users.noreply.github.com> Date: Tue, 1 Apr 2025 16:52:58 -0400 Subject: [PATCH 2/3] Fixing header formatting so header is inside orange (#106) --- frontend/src/grant-info/components/GrantLabels.tsx | 2 +- frontend/src/grant-info/components/GrantList.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/grant-info/components/GrantLabels.tsx b/frontend/src/grant-info/components/GrantLabels.tsx index 9dc5072..9438286 100644 --- a/frontend/src/grant-info/components/GrantLabels.tsx +++ b/frontend/src/grant-info/components/GrantLabels.tsx @@ -18,7 +18,7 @@ const GrantLabels: React.FC<{ } return ( -