diff --git a/frontend/.env.development b/frontend/.env.development index 7941f8929..57f73eb12 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -1,5 +1,2 @@ # The URL where the server runs -REACT_APP_SERVER_URL="http://localhost:3000" - -# The URL where the Apollo server runs -REACT_APP_GRAPHQL_URL="http://localhost:3000/graphql" \ No newline at end of file +REACT_APP_SERVER_URL="http://localhost:3000" \ No newline at end of file diff --git a/frontend/src/apolloClient.ts b/frontend/src/apolloClient.ts index 5ad6ca62e..4eb5e6c76 100644 --- a/frontend/src/apolloClient.ts +++ b/frontend/src/apolloClient.ts @@ -21,7 +21,7 @@ const mergeByReplacement: { merge: FieldMergeFunction } = { export const apolloClient = new ApolloClient({ link: new HttpLink({ - uri: process.env.REACT_APP_GRAPHQL_URL, + uri: `${process.env.REACT_APP_SERVER_URL?.replace(/\/$/, '')}/graphql`, credentials: 'include', }), cache: new InMemoryCache({ diff --git a/frontend/src/components/UserProfileContext.tsx b/frontend/src/components/UserProfileContext.tsx index f79e8d049..cf9d1944e 100644 --- a/frontend/src/components/UserProfileContext.tsx +++ b/frontend/src/components/UserProfileContext.tsx @@ -1,6 +1,6 @@ import { createContext, FunctionComponent, useEffect, useState } from 'react' -const SERVER_URL = process.env.REACT_APP_SERVER_URL +const SERVER_URL = process.env.REACT_APP_SERVER_URL?.replace(/\/$/, '') export interface UserProfile { id: number diff --git a/frontend/src/hooks/useAuth.tsx b/frontend/src/hooks/useAuth.tsx index fb0fbdc9d..0f5344b43 100644 --- a/frontend/src/hooks/useAuth.tsx +++ b/frontend/src/hooks/useAuth.tsx @@ -24,7 +24,7 @@ export const AuthContext = createContext({ export const useAuth = () => useContext(AuthContext) -const SERVER_URL = process.env.REACT_APP_SERVER_URL +const SERVER_URL = process.env.REACT_APP_SERVER_URL?.replace(/\/$/, '') const headers = { 'content-type': 'application/json; charset=utf-8', diff --git a/frontend/src/pages/shipments/DownloadCSVMenu.tsx b/frontend/src/pages/shipments/DownloadCSVMenu.tsx index 4cae8a632..5498d7b84 100644 --- a/frontend/src/pages/shipments/DownloadCSVMenu.tsx +++ b/frontend/src/pages/shipments/DownloadCSVMenu.tsx @@ -12,7 +12,7 @@ interface Props { shipment: ShipmentQuery['shipment'] } -const SERVER_URL = process.env.REACT_APP_SERVER_URL +const SERVER_URL = process.env.REACT_APP_SERVER_URL?.replace(/\/$/, '') const DownloadCSVMenu: FunctionComponent = ({ shipment }) => { const [modalIsVisible, showModal, hideModal] = useModalState()