2ab499bc54
- 修改 Dockerfile 中的运行命令,将 Next.js 设为对外服务,Go 服务在内部监听 - 更新端口配置,后端监听端口从 3000 改为 80 - 移除 Go 服务中的反向代理逻辑,统一由 Next.js 处理页面请求 - 修改 Next.js 配置,在生产环境中也启用 API 代理功能 - 更新文档描述,明确 Next.js 作为页面入口,API 请求代理到 Go 服务 - 调整开发环境端口配置,web 开发端口从 3001 改为 3000 - 更新版本号至 v0.0.4 并修改 CHANGELOG
28 lines
961 B
TypeScript
28 lines
961 B
TypeScript
import type { NextConfig } from "next";
|
|
import { PHASE_DEVELOPMENT_SERVER } from "next/constants";
|
|
import { loadEnvConfig } from "@next/env";
|
|
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname, resolve } from "node:path";
|
|
|
|
const webDir = dirname(fileURLToPath(import.meta.url));
|
|
const version = readFileSync(resolve(webDir, "../VERSION"), "utf8").trim() || "dev";
|
|
|
|
export default function nextConfig(phase: string): NextConfig {
|
|
const isDev = phase === PHASE_DEVELOPMENT_SERVER;
|
|
loadEnvConfig(resolve(webDir, ".."), isDev, undefined, true);
|
|
const apiBaseUrl = process.env.API_BASE_URL || "http://127.0.0.1:8080";
|
|
return {
|
|
allowedDevOrigins: isDev ? ["*.*.*.*"] : [],
|
|
typescript: {
|
|
ignoreBuildErrors: true,
|
|
},
|
|
env: {
|
|
NEXT_PUBLIC_APP_VERSION: version,
|
|
},
|
|
async rewrites() {
|
|
return [{ source: "/api/:path*", destination: `${apiBaseUrl}/api/:path*` }];
|
|
},
|
|
};
|
|
}
|