use proxy for local development

This commit is contained in:
Emmy D'Anello 2024-02-02 01:08:18 +01:00
parent 74a5cf7cbf
commit c6d481556b
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
3 changed files with 8 additions and 7 deletions

View File

@ -45,5 +45,6 @@
"last 1 firefox version",
"last 1 safari version"
]
}
},
"proxy": "http://localhost:8000"
}

View File

@ -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,
})

View File

@ -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,
})),