.env.local 文件在 frontend 目录下创建 .env.local 文件(如果不存在)。
在 .env.local 文件中添加以下内容:
# 将 192.168.124.9 替换为你的电脑 IP 地址
# 获取 IP 地址:在 PowerShell 中运行 ipconfig
NEXT_PUBLIC_API_BASE_URL=http://192.168.124.9:8080
你的 IP 地址:根据 ipconfig 结果,你的 IP 地址是 192.168.124.9
# 停止当前服务(Ctrl+C)
# 重新启动
npm run dev
http://192.168.124.9:3000如果只想在本地开发,不需要配置 .env.local 文件,使用默认配置即可:
http://localhost:3000http://127.0.0.1:80800.0.0.0:8080,允许外部访问Windows PowerShell:
# 在 frontend 目录下运行
@"
NEXT_PUBLIC_API_BASE_URL=http://192.168.124.9:8080
"@ | Out-File -FilePath ".env.local" -Encoding utf8
(记得将 192.168.124.9 替换为你的实际 IP 地址)