diff --git a/frontend/src/api/graphql.ts b/frontend/src/api/graphql.ts index cec2cb2..2e1192e 100644 --- a/frontend/src/api/graphql.ts +++ b/frontend/src/api/graphql.ts @@ -7,11 +7,11 @@ type GraphQLResponse = { errors?: GraphQLError[]; }; +import { GRAPHQL_URL } from "./graphqlUrl"; + /** * Hva gjør dette? Trenger vi det hvis vi har apollo client? */ -const GRAPHQL_URL = import.meta.env.VITE_GRAPHQL_URL ?? "http://localhost:3001/"; - export async function graphqlRequest( query: string, variables?: Record, diff --git a/frontend/src/api/graphqlUrl.ts b/frontend/src/api/graphqlUrl.ts new file mode 100644 index 0000000..f9c6d8d --- /dev/null +++ b/frontend/src/api/graphqlUrl.ts @@ -0,0 +1,5 @@ +const defaultGraphqlUrl = import.meta.env.DEV + ? "http://localhost:3001/" + : `${window.location.protocol}//${window.location.hostname}:3001/`; + +export const GRAPHQL_URL = import.meta.env.VITE_GRAPHQL_URL || defaultGraphqlUrl; \ No newline at end of file diff --git a/frontend/src/apollo/client.ts b/frontend/src/apollo/client.ts index 853885a..7fb7994 100644 --- a/frontend/src/apollo/client.ts +++ b/frontend/src/apollo/client.ts @@ -3,11 +3,12 @@ import { InMemoryCache, HttpLink, } from "@apollo/client"; +import { GRAPHQL_URL } from "../api/graphqlUrl"; export const apolloClient = new ApolloClient({ link: new HttpLink({ - uri: "http://localhost:3001", + uri: GRAPHQL_URL, }), cache: new InMemoryCache(), }); \ No newline at end of file diff --git a/frontend/src/pages/ThreatActors/ThreatActorDetailed.tsx b/frontend/src/pages/ThreatActors/ThreatActorDetailed.tsx index c7ddaae..e561fdc 100644 --- a/frontend/src/pages/ThreatActors/ThreatActorDetailed.tsx +++ b/frontend/src/pages/ThreatActors/ThreatActorDetailed.tsx @@ -30,7 +30,7 @@ function ThreatActorDetailed() { ); //Henter ut Assosierte Techniques - const {data: techniquesData, loading: techniquesLoading, error: techniquesError} = useQuery(GET_THREAT_ACTOR_TECHNIQUES, { + const {data: techniquesData} = useQuery(GET_THREAT_ACTOR_TECHNIQUES, { variables: { mitreId: mitreId ?? "", limit: PAGE_SIZE, @@ -40,7 +40,7 @@ function ThreatActorDetailed() { }); //Henter ut Assosierte Softwares - const {data: softwaresData, loading: softwaresLoading, error: softwaresError} = useQuery(GET_THREAT_ACTOR_SOFTWARES, { + const {data: softwaresData} = useQuery(GET_THREAT_ACTOR_SOFTWARES, { variables: { mitreId: mitreId ?? "", limit: PAGE_SIZE, diff --git a/frontend/src/pages/ThreatActors/ThreatActors.tsx b/frontend/src/pages/ThreatActors/ThreatActors.tsx index 5444d22..1c54030 100644 --- a/frontend/src/pages/ThreatActors/ThreatActors.tsx +++ b/frontend/src/pages/ThreatActors/ThreatActors.tsx @@ -12,7 +12,7 @@ function ThreatActor(){ const pageSize = 9; const [page, setPage] = useState(1); - const {data, loading, error} = useQuery(GET_ALL_THREAT_ACTOR_GRID, { + const {data} = useQuery(GET_ALL_THREAT_ACTOR_GRID, { variables: { limit: pageSize, offset: (page - 1) * pageSize diff --git a/frontend/src/routes/AppRoutes.tsx b/frontend/src/routes/AppRoutes.tsx index 0b6988f..5bbbe51 100644 --- a/frontend/src/routes/AppRoutes.tsx +++ b/frontend/src/routes/AppRoutes.tsx @@ -23,7 +23,7 @@ import TechniqueDetailed from "../pages/Techniques/TechniqueDetailed"; */ function AppRoutes() { return ( - + }> } />