diff --git a/app/api/bff/route.ts b/app/api/bff/route.ts index c276930..bb8acaa 100644 --- a/app/api/bff/route.ts +++ b/app/api/bff/route.ts @@ -13,7 +13,7 @@ export async function POST(request: NextRequest) { } // 转发到后端GraphQL - const response = await fetch(process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql', { + const response = await fetch(process.env.NEXT_PUBLIC_GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/app/api/login/route.ts b/app/api/login/route.ts index c3d9107..49aba43 100644 --- a/app/api/login/route.ts +++ b/app/api/login/route.ts @@ -22,7 +22,7 @@ export async function POST(request: NextRequest) { ); } - const client = new GraphQLClient(process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql'); + const client = new GraphQLClient(process.env.NEXT_PUBLIC_GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql'); const response: any = await client.request(LOGIN_MUTATION, { username, password }); const jwt = response.login.token; @@ -39,7 +39,6 @@ export async function POST(request: NextRequest) { } catch (error) { - console.log(process.env.GRAPHQL_BACKEND_URL) console.error('Login error:', error); return NextResponse.json( diff --git a/app/api/session/sync/route.ts b/app/api/session/sync/route.ts index 893d577..416e184 100644 --- a/app/api/session/sync/route.ts +++ b/app/api/session/sync/route.ts @@ -34,7 +34,7 @@ export async function POST(request: NextRequest) { const jwt = body.jwt; - const client = new GraphQLClient(process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql', { + const client = new GraphQLClient(process.env.NEXT_PUBLIC_GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql', { headers: { 'Authorization': `Bearer ${jwt}` } diff --git a/app/api/site/route.ts b/app/api/site/route.ts index af75e49..0c4c5dc 100644 --- a/app/api/site/route.ts +++ b/app/api/site/route.ts @@ -12,7 +12,7 @@ const GET_CONFIGS = gql` ` export async function GET(request: NextRequest) { - const client = new GraphQLClient(process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql'); + const client = new GraphQLClient(process.env.NEXT_PUBLIC_GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql'); try { const data: any = await client.request(GET_CONFIGS); return NextResponse.json(data.siteConfigs); diff --git a/app/tl.tsx b/app/tl.tsx index 5ee6b83..47b95d5 100644 --- a/app/tl.tsx +++ b/app/tl.tsx @@ -164,7 +164,9 @@ export const Timeline: React.FC = React.memo(({ }, onDateChange: async (date: Date) => { const datestr = formatInTimeZone(date, 'UTC', 'yyyyMMddHHmmss') - const url_base = process.env.GRAPHQL_BACKEND_URL?.replace('/graphql', '') || 'http://localhost:3050' + const url_base = process.env.NEXT_PUBLIC_GRAPHQL_BACKEND_URL?.replace('/graphql', '') || 'http://localhost:3050' + // const url_base = "http://45.152.65.37:3050" + const response = await fetch(`${url_base}/api/v1/data/nearest?datetime=${datestr}&area=cn`) setTimelineTime(date) @@ -243,7 +245,8 @@ export const Timeline: React.FC = React.memo(({ const date = new Date() const datestr = formatInTimeZone(date, 'UTC', 'yyyyMMddHHmmss') - const url_base = process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050' + const url_base = process.env.NEXT_PUBLIC_GRAPHQL_BACKEND_URL || 'http://localhost:3050' + // const url_base = "http://45.152.65.37:3050" const response = await fetch(`${url_base}/api/v1/data/nearest?datetime=${datestr}&area=cn`) if (response.ok) { const data = await response.json() diff --git a/components/map-component.tsx b/components/map-component.tsx index e23d878..cefa5c5 100644 --- a/components/map-component.tsx +++ b/components/map-component.tsx @@ -58,7 +58,7 @@ export function MapComponent({ useEffect(() => { if (!isMapReady || !currentDatetime) return; const utc_time_str = formatInTimeZone(currentDatetime, 'UTC', 'yyyyMMddHHmmss') - const new_url_prefix = process.env.GRAPHQL_BACKEND_URL?.replace('/graphql', '') || 'http://localhost:3050' + const new_url_prefix = process.env.NEXT_PUBLIC_GRAPHQL_BACKEND_URL?.replace('/graphql', '') || 'http://localhost:3050' const new_url = `${new_url_prefix}/api/v1/data?datetime=${utc_time_str}&area=cn` fetchRadarTile(new_url) }, [currentDatetime, isMapReady]) diff --git a/lib/apollo-client.ts b/lib/apollo-client.ts index 57a39e6..780657e 100644 --- a/lib/apollo-client.ts +++ b/lib/apollo-client.ts @@ -8,12 +8,14 @@ import { createClient } from 'graphql-ws'; const TOKEN_KEY = 'auth_token'; const httpLink = createHttpLink({ - uri: process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql', + uri: process.env.NEXT_PUBLIC_GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql', + // uri: "http://45.152.65.37:3050/graphql" }); const wsLink = new GraphQLWsLink(createClient({ // url: "ws://127.0.0.1:3050/ws", - url: process.env.GRAPHQL_BACKEND_URL?.replace('/graphql', '/ws')?.replace('http://', 'ws://') || 'ws://localhost:3050/ws', + url: process.env.NEXT_PUBLIC_GRAPHQL_BACKEND_URL?.replace('/graphql', '/ws')?.replace('http://', 'ws://') || 'ws://localhost:3050/ws', + // url: "ws://45.152.65.37:3050/ws" })); const authLink = setContext((_, { headers }) => {