env error
This commit is contained in:
parent
9cb46de3e1
commit
f4c4e8a3b5
@ -13,7 +13,7 @@ export async function POST(request: NextRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 转发到后端GraphQL
|
// 转发到后端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',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
@ -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 response: any = await client.request(LOGIN_MUTATION, { username, password });
|
||||||
|
|
||||||
const jwt = response.login.token;
|
const jwt = response.login.token;
|
||||||
@ -39,7 +39,6 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(process.env.GRAPHQL_BACKEND_URL)
|
|
||||||
|
|
||||||
console.error('Login error:', error);
|
console.error('Login error:', error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|||||||
@ -34,7 +34,7 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
const jwt = body.jwt;
|
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: {
|
headers: {
|
||||||
'Authorization': `Bearer ${jwt}`
|
'Authorization': `Bearer ${jwt}`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ const GET_CONFIGS = gql`
|
|||||||
`
|
`
|
||||||
|
|
||||||
export async function GET(request: NextRequest) {
|
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 {
|
try {
|
||||||
const data: any = await client.request(GET_CONFIGS);
|
const data: any = await client.request(GET_CONFIGS);
|
||||||
return NextResponse.json(data.siteConfigs);
|
return NextResponse.json(data.siteConfigs);
|
||||||
|
|||||||
@ -164,7 +164,9 @@ export const Timeline: React.FC<Props> = React.memo(({
|
|||||||
},
|
},
|
||||||
onDateChange: async (date: Date) => {
|
onDateChange: async (date: Date) => {
|
||||||
const datestr = formatInTimeZone(date, 'UTC', 'yyyyMMddHHmmss')
|
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`)
|
const response = await fetch(`${url_base}/api/v1/data/nearest?datetime=${datestr}&area=cn`)
|
||||||
|
|
||||||
setTimelineTime(date)
|
setTimelineTime(date)
|
||||||
@ -243,7 +245,8 @@ export const Timeline: React.FC<Props> = React.memo(({
|
|||||||
|
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
const datestr = formatInTimeZone(date, 'UTC', 'yyyyMMddHHmmss')
|
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`)
|
const response = await fetch(`${url_base}/api/v1/data/nearest?datetime=${datestr}&area=cn`)
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
|
|||||||
@ -58,7 +58,7 @@ export function MapComponent({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isMapReady || !currentDatetime) return;
|
if (!isMapReady || !currentDatetime) return;
|
||||||
const utc_time_str = formatInTimeZone(currentDatetime, 'UTC', 'yyyyMMddHHmmss')
|
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`
|
const new_url = `${new_url_prefix}/api/v1/data?datetime=${utc_time_str}&area=cn`
|
||||||
fetchRadarTile(new_url)
|
fetchRadarTile(new_url)
|
||||||
}, [currentDatetime, isMapReady])
|
}, [currentDatetime, isMapReady])
|
||||||
|
|||||||
@ -8,12 +8,14 @@ import { createClient } from 'graphql-ws';
|
|||||||
const TOKEN_KEY = 'auth_token';
|
const TOKEN_KEY = 'auth_token';
|
||||||
|
|
||||||
const httpLink = createHttpLink({
|
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({
|
const wsLink = new GraphQLWsLink(createClient({
|
||||||
// url: "ws://127.0.0.1:3050/ws",
|
// 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 }) => {
|
const authLink = setContext((_, { headers }) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user