diff --git a/.env b/.env index 09ebf1e2..72fa1ace 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ # solves issues with stylis-plugin-rtl : https://github.com/styled-components/stylis-plugin-rtl/issues/35#issuecomment-1550877823 -GENERATE_SOURCEMAP=false \ No newline at end of file +GENERATE_SOURCEMAP=false +VITE_API_URI=https://open-bus-stride-api.hasadna.org.il/ \ No newline at end of file diff --git a/src/api/agencyList.ts b/src/api/agencyList.ts index 9a0c1a93..946c8d8b 100644 --- a/src/api/agencyList.ts +++ b/src/api/agencyList.ts @@ -4,13 +4,13 @@ export interface Agency { agency_name: string // example - "אלקטרה אפיקים" } -let json: Promise +let json: Agency[] export default async function getAgencyList(): Promise { if (!json) { - json = fetch('https://open-bus-stride-api.hasadna.org.il/gtfs_agencies/list').then((response) => - response.json(), - ) + const response = await fetch(`${import.meta.env.VITE_API_URI}gtfs_agencies/list`) + json = await response.json() } + return json } diff --git a/src/api/apiConfig.ts b/src/api/apiConfig.ts index 04ab1981..a0d6da7b 100644 --- a/src/api/apiConfig.ts +++ b/src/api/apiConfig.ts @@ -1,7 +1,7 @@ import { Configuration } from 'open-bus-stride-client' //const BASE_PATH = 'http://localhost:3000/api' -export const BASE_PATH = 'https://open-bus-stride-api.hasadna.org.il' +export const BASE_PATH = import.meta.env.VITE_API_URI export const API_CONFIG = new Configuration({ basePath: BASE_PATH }) export const MAX_HITS_COUNT = 16