From c6d481556b749d355e4820e15becfeb8e95fd075 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Fri, 2 Feb 2024 01:08:18 +0100 Subject: [PATCH] use proxy for local development --- sncf-station/package.json | 3 ++- sncf-station/src/Station.js | 2 +- sncf-station/src/TrainsTable.js | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sncf-station/package.json b/sncf-station/package.json index ce6c5f5..06deeb8 100644 --- a/sncf-station/package.json +++ b/sncf-station/package.json @@ -45,5 +45,6 @@ "last 1 firefox version", "last 1 safari version" ] - } + }, + "proxy": "http://localhost:8000" } diff --git a/sncf-station/src/Station.js b/sncf-station/src/Station.js index ec636c9..d25b011 100644 --- a/sncf-station/src/Station.js +++ b/sncf-station/src/Station.js @@ -31,7 +31,7 @@ function Station() { useQueryClient() const stopQuery = useQuery({ queryKey: ['stop', stopId], - queryFn: () => fetch(`http://localhost:8000/api/gtfs/stop/${stopId}/`) + queryFn: () => fetch(`/api/gtfs/stop/${stopId}/`) .then(response => response.json()), enabled: !!stopId, }) diff --git a/sncf-station/src/TrainsTable.js b/sncf-station/src/TrainsTable.js index 504f1b9..7f1fa06 100644 --- a/sncf-station/src/TrainsTable.js +++ b/sncf-station/src/TrainsTable.js @@ -62,7 +62,7 @@ function TrainsTableBody({stop, date, time, tableType}) { } function updateTrains() { - return fetch(`http://localhost:8000/api/station/next_${tableType}/?stop_id=${stop.id}&date=${date}&time=${time}&offset=${0}&limit=${20}`) + return fetch(`/api/station/next_${tableType}/?stop_id=${stop.id}&date=${date}&time=${time}&offset=${0}&limit=${20}`) .then(response => response.json()) .then(data => data.results) .then(data => [...data]) @@ -98,7 +98,7 @@ function TrainsTableBody({stop, date, time, tableType}) { function TrainRow({train, tableType}) { const tripQuery = useQuery({ queryKey: ['trip', train.trip], - queryFn: () => fetch(`http://localhost:8000/api/gtfs/trip/${train.trip}/`) + queryFn: () => fetch(`/api/gtfs/trip/${train.trip}/`) .then(response => response.json()), enabled: !!train.trip, }) @@ -106,7 +106,7 @@ function TrainRow({train, tableType}) { const routeQuery = useQuery({ queryKey: ['route', trip.route], - queryFn: () => fetch(`http://localhost:8000/api/gtfs/route/${trip.route}/`) + queryFn: () => fetch(`/api/gtfs/route/${trip.route}/`) .then(response => response.json()), enabled: !!trip.route, }) @@ -115,7 +115,7 @@ function TrainRow({train, tableType}) { const stopTimesQuery = useQuery({ queryKey: ['stop_times', trip.id], - queryFn: () => fetch(`http://localhost:8000/api/gtfs/stop_time/?trip=${trip.id}&order=stop_sequence&limit=1000`) + queryFn: () => fetch(`/api/gtfs/stop_time/?trip=${trip.id}&order=stop_sequence&limit=1000`) .then(response => response.json()) .then(data => data.results), enabled: !!trip.id, @@ -126,7 +126,7 @@ function TrainRow({train, tableType}) { const stopQueries = useQueries({ queries: stopIds.map(stopId => ({ queryKey: ['stop', stopId], - queryFn: () => fetch(`http://localhost:8000/api/gtfs/stop/${stopId}/`) + queryFn: () => fetch(`/api/gtfs/stop/${stopId}/`) .then(response => response.json()), enabled: !!stopId, })),