From 69920992981ab4806ad1c87651f169b9f7b8d1ba Mon Sep 17 00:00:00 2001 From: Tsuki Date: Thu, 14 Aug 2025 00:33:48 +0800 Subject: [PATCH] add env --- README.md | 2 +- app/tl.tsx | 6 ++++-- components/map-component.tsx | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e215bc4..43a546d 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ pnpm dev bun dev ``` -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. +Open [http://3000](http://localhost:3000) with your browser to see the result. You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. diff --git a/app/tl.tsx b/app/tl.tsx index 88d8735..dd034d4 100644 --- a/app/tl.tsx +++ b/app/tl.tsx @@ -163,7 +163,8 @@ export const Timeline: React.FC = React.memo(({ }, onDateChange: async (date: Date) => { const datestr = formatInTimeZone(date, 'UTC', 'yyyyMMddHHmmss') - const response = await fetch(`http://localhost:3050/api/v1/data/nearest?datetime=${datestr}&area=cn`) + const url_base = process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050' + const response = await fetch(`${url_base}/api/v1/data/nearest?datetime=${datestr}&area=cn`) setTimelineTime(date) if (response.ok) { @@ -241,7 +242,8 @@ export const Timeline: React.FC = React.memo(({ const date = new Date() const datestr = formatInTimeZone(date, 'UTC', 'yyyyMMddHHmmss') - const response = await fetch(`http://localhost:3050/api/v1/data/nearest?datetime=${datestr}&area=cn`) + const url_base = process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050' + const response = await fetch(`${url_base}/api/v1/data/nearest?datetime=${datestr}&area=cn`) if (response.ok) { const data = await response.json() const nearestDatetime = data.nearest_data_time diff --git a/components/map-component.tsx b/components/map-component.tsx index 6e5d31a..02c1912 100644 --- a/components/map-component.tsx +++ b/components/map-component.tsx @@ -58,7 +58,8 @@ export function MapComponent({ useEffect(() => { if (!isMapReady || !currentDatetime) return; const utc_time_str = formatInTimeZone(currentDatetime, 'UTC', 'yyyyMMddHHmmss') - const new_url = `http://localhost:3050/api/v1/data?datetime=${utc_time_str}&area=cn` + const new_url_prefix = process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050' + const new_url = `${new_url_prefix}/api/v1/data?datetime=${utc_time_str}&area=cn` fetchRadarTile(new_url) }, [currentDatetime, isMapReady])