diff --git a/.env b/.env index 09ebf1e2..06241363 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_BASE_PATH=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..216506d5 100644 --- a/src/api/agencyList.ts +++ b/src/api/agencyList.ts @@ -1,16 +1,17 @@ +import { BASE_PATH } from './apiConfig' export interface Agency { date: string // example - "2019-07-01" operator_ref: number // example - 25, 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(`${BASE_PATH}/gtfs_agencies/list`) + json = await response.json() } + return json } diff --git a/src/api/apiConfig.ts b/src/api/apiConfig.ts index 04ab1981..6ce064af 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_BASE_PATH export const API_CONFIG = new Configuration({ basePath: BASE_PATH }) export const MAX_HITS_COUNT = 16