From 713c7af724907511f94a501391bd365752d44af4 Mon Sep 17 00:00:00 2001 From: Angelica Ochoa <15623749+ao508@users.noreply.github.com> Date: Tue, 6 Aug 2024 10:44:13 -0400 Subject: [PATCH] Consolidate environment variables Signed-off-by: Angelica Ochoa <15623749+ao508@users.noreply.github.com> --- frontend/src/index.tsx | 4 ++-- frontend/src/pages/auth/LoginSuccessPage.tsx | 4 ++-- frontend/src/shared/components/SmileNavBar.tsx | 4 ++-- frontend/src/shared/constants.ts | 12 ++++++------ frontend/src/utils/getUserEmail.ts | 4 ++-- frontend/src/utils/openLoginPopup.ts | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index c5f29889..c6315a40 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -5,7 +5,7 @@ import { ApolloClient, InMemoryCache, ApolloProvider } from "@apollo/client"; import { BrowserRouter } from "react-router-dom"; import { offsetLimitPagination } from "@apollo/client/utilities"; import App from "./App"; -import { REACT_APP_EXPRESS_SERVER_ORIGIN } from "./shared/constants"; +import { EXPRESS_SERVER_ORIGIN } from "./shared/constants"; const cache = new InMemoryCache({ /* @ts-ignore */ @@ -28,7 +28,7 @@ const cache = new InMemoryCache({ }); const client = new ApolloClient({ - uri: `${REACT_APP_EXPRESS_SERVER_ORIGIN}/graphql`, + uri: `${EXPRESS_SERVER_ORIGIN}/graphql`, cache, credentials: "include", connectToDevTools: true, diff --git a/frontend/src/pages/auth/LoginSuccessPage.tsx b/frontend/src/pages/auth/LoginSuccessPage.tsx index 469d8154..e74c979e 100644 --- a/frontend/src/pages/auth/LoginSuccessPage.tsx +++ b/frontend/src/pages/auth/LoginSuccessPage.tsx @@ -1,10 +1,10 @@ import { useEffect } from "react"; -import { REACT_APP_REACT_SERVER_ORIGIN } from "../../shared/constants"; +import { REACT_SERVER_ORIGIN } from "../../shared/constants"; export default function LoginSuccessPage() { useEffect(() => { if (window.opener) { - window.opener.postMessage("success", `${REACT_APP_REACT_SERVER_ORIGIN}`); + window.opener.postMessage("success", `${REACT_SERVER_ORIGIN}`); window.onload = () => { setTimeout(() => { diff --git a/frontend/src/shared/components/SmileNavBar.tsx b/frontend/src/shared/components/SmileNavBar.tsx index 1d6753a8..81679f34 100644 --- a/frontend/src/shared/components/SmileNavBar.tsx +++ b/frontend/src/shared/components/SmileNavBar.tsx @@ -1,5 +1,5 @@ import { Nav, NavLink } from "react-bootstrap"; -import { REACT_APP_EXPRESS_SERVER_ORIGIN } from "../constants"; +import { EXPRESS_SERVER_ORIGIN } from "../constants"; import { Dispatch, SetStateAction } from "react"; export default function SmileNavBar({ @@ -10,7 +10,7 @@ export default function SmileNavBar({ setUserEmail: Dispatch>; }) { function handleLogout() { - fetch(`${REACT_APP_EXPRESS_SERVER_ORIGIN}/auth/logout`, { + fetch(`${EXPRESS_SERVER_ORIGIN}/auth/logout`, { method: "POST", credentials: "include", mode: "no-cors", diff --git a/frontend/src/shared/constants.ts b/frontend/src/shared/constants.ts index 3f1c9b2e..eeffb293 100644 --- a/frontend/src/shared/constants.ts +++ b/frontend/src/shared/constants.ts @@ -1,9 +1,9 @@ -export const REACT_APP_EXPRESS_SERVER_ORIGIN = - process.env.REACT_APP_EXPRESS_SERVER_ORIGIN === undefined +export const EXPRESS_SERVER_ORIGIN = + process.env.EXPRESS_SERVER_ORIGIN === undefined ? "https://localhost:4000" - : process.env.REACT_APP_EXPRESS_SERVER_ORIGIN; + : process.env.EXPRESS_SERVER_ORIGIN; -export const REACT_APP_REACT_SERVER_ORIGIN = - process.env.REACT_APP_REACT_SERVER_ORIGIN === undefined +export const REACT_SERVER_ORIGIN = + process.env.REACT_SERVER_ORIGIN === undefined ? "https://localhost:3006" - : process.env.REACT_APP_REACT_SERVER_ORIGIN; + : process.env.REACT_SERVER_ORIGIN; diff --git a/frontend/src/utils/getUserEmail.ts b/frontend/src/utils/getUserEmail.ts index dee0834a..5cbb693d 100644 --- a/frontend/src/utils/getUserEmail.ts +++ b/frontend/src/utils/getUserEmail.ts @@ -1,9 +1,9 @@ -import { REACT_APP_EXPRESS_SERVER_ORIGIN } from "../shared/constants"; +import { EXPRESS_SERVER_ORIGIN } from "../shared/constants"; export async function getUserEmail() { try { const response = await fetch( - `${REACT_APP_EXPRESS_SERVER_ORIGIN}/auth/get-user-email`, + `${EXPRESS_SERVER_ORIGIN}/auth/get-user-email`, { credentials: "include", } diff --git a/frontend/src/utils/openLoginPopup.ts b/frontend/src/utils/openLoginPopup.ts index e97a0537..67f09417 100644 --- a/frontend/src/utils/openLoginPopup.ts +++ b/frontend/src/utils/openLoginPopup.ts @@ -1,4 +1,4 @@ -import { REACT_APP_EXPRESS_SERVER_ORIGIN } from "../shared/constants"; +import { EXPRESS_SERVER_ORIGIN } from "../shared/constants"; export function openLoginPopup() { const width = 800; @@ -7,7 +7,7 @@ export function openLoginPopup() { const top = (window.screen.height - height) / 2; window.open( - `${REACT_APP_EXPRESS_SERVER_ORIGIN}/auth/login`, + `${EXPRESS_SERVER_ORIGIN}/auth/login`, "_blank", `toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${width}, height=${height}, top=${top}, left=${left}` );