使用动态API地址
This commit is contained in:
@@ -3,7 +3,10 @@
|
|||||||
|
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
|
|
||||||
const API_BASE = ""; // 使用相对路径,由 Next.js rewrite 代理到后端
|
// 动态获取 API 地址:服务端使用 localhost,客户端使用当前域名
|
||||||
|
const API_BASE = typeof window !== 'undefined'
|
||||||
|
? `http://${window.location.hostname}:8006`
|
||||||
|
: 'http://localhost:8006';
|
||||||
|
|
||||||
// 类型定义
|
// 类型定义
|
||||||
interface Material {
|
interface Material {
|
||||||
|
|||||||
@@ -3,7 +3,10 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
const API_BASE = ""; // 使用相对路径,由 Next.js rewrite 代理到后端
|
// 动态获取 API 地址:服务端使用 localhost,客户端使用当前域名
|
||||||
|
const API_BASE = typeof window !== 'undefined'
|
||||||
|
? `http://${window.location.hostname}:8006`
|
||||||
|
: 'http://localhost:8006';
|
||||||
|
|
||||||
interface Account {
|
interface Account {
|
||||||
platform: string;
|
platform: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user