Skip to content

Commit

Permalink
Consolidate environment variables
Browse files Browse the repository at this point in the history
Signed-off-by: Angelica Ochoa <[email protected]>
  • Loading branch information
ao508 committed Aug 6, 2024
1 parent 6bb7351 commit 713c7af
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/auth/LoginSuccessPage.tsx
Original file line number Diff line number Diff line change
@@ -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(() => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/shared/components/SmileNavBar.tsx
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -10,7 +10,7 @@ export default function SmileNavBar({
setUserEmail: Dispatch<SetStateAction<string | null>>;
}) {
function handleLogout() {
fetch(`${REACT_APP_EXPRESS_SERVER_ORIGIN}/auth/logout`, {
fetch(`${EXPRESS_SERVER_ORIGIN}/auth/logout`, {
method: "POST",
credentials: "include",
mode: "no-cors",
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/shared/constants.ts
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions frontend/src/utils/getUserEmail.ts
Original file line number Diff line number Diff line change
@@ -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",
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utils/openLoginPopup.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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}`
);
Expand Down

0 comments on commit 713c7af

Please sign in to comment.