nomadro/next.config.ts
Eric 5271aabc98 Ship social selfie face-check, avatar UX by device, blog/admin, and notify polish.
Add InsightFace/OpenCV challenge upload, PC vs mobile capture branching, and fix avatar persistence into roster/profile pages.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-04 14:38:20 +08:00

148 lines
4.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import path from "node:path";
import type { NextConfig } from "next";
const API_URL = (process.env.API_URL || "http://127.0.0.1:8080").replace(
/\/$/,
"",
);
/** Social IM is isolated (nomadro-social / portal nginx /rt). Never assume api.* hosts it. */
const SOCIAL_API_URL = (
process.env.SOCIAL_API_URL ||
(/\bapi\.nomadro\.(com|cn)\b/i.test(API_URL)
? API_URL.replace(/\bapi\.(nomadro\.(?:com|cn))\b/i, "$1")
: API_URL)
).replace(/\/$/, "");
/**
* Micro-frontend upstreams (Planka / Etherpad).
* Local without Docker: set WORK_*_ORIGIN in `.env.local` (e.g. US host :1337/:9001).
*/
const WORK_PLANKA_ORIGIN = (
process.env.WORK_PLANKA_ORIGIN || "http://127.0.0.1:1337"
).replace(/\/$/, "");
const WORK_ETHERPAD_ORIGIN = (
process.env.WORK_ETHERPAD_ORIGIN || "http://127.0.0.1:9001"
).replace(/\/$/, "");
if (process.env.NODE_ENV !== "production") {
console.info(
`[work] planka-api→${WORK_PLANKA_ORIGIN} etherpad→${WORK_ETHERPAD_ORIGIN}`,
);
}
/** 门户前端均在 src/;禁止再指向已删除的垂直仓 */
const aliases = {
"@ebook": path.resolve(__dirname, "src/modules/ebook"),
"@community": path.resolve(__dirname, "src/modules/community"),
"@social": path.resolve(__dirname, "src/modules/social"),
"@navmini": path.resolve(__dirname, "src/modules/nav"),
"@vip": path.resolve(__dirname, "src/modules/vip"),
"@work": path.resolve(__dirname, "src/modules/work"),
"@nomadro/pay": path.resolve(__dirname, "packages/pay/src/index.ts"),
"@nomadro/pb": path.resolve(__dirname, "packages/pb/src/index.ts"),
"@nomadro/sdk": path.resolve(__dirname, "packages/sdk/src/index.ts"),
};
const nextConfig: NextConfig = {
poweredByHeader: false,
compress: true,
typescript: {
// 生产机内存紧;social/centrifugo 发版勿被无关 admin TS 卡死
ignoreBuildErrors: true,
},
experimental: {
externalDir: true,
optimizePackageImports: [
"antd",
"@ant-design/icons",
"lucide-react",
"framer-motion",
"three",
],
},
images: {
formats: ["image/avif", "image/webp"],
remotePatterns: [
{ protocol: "https", hostname: "**.nomadro.cn" },
{ protocol: "https", hostname: "**.nomadro.com" },
{ protocol: "https", hostname: "s3.nomadro.com" },
{ protocol: "https", hostname: "api.dicebear.com" },
],
},
transpilePackages: ["@nomadro/pay", "@nomadro/pb", "@nomadro/sdk"],
turbopack: {
resolveAlias: {
"@ebook": "./src/modules/ebook",
"@community": "./src/modules/community",
"@social": "./src/modules/social",
"@navmini": "./src/modules/nav",
"@vip": "./src/modules/vip",
"@work": "./src/modules/work",
"@nomadro/pay": "./packages/pay/src/index.ts",
"@nomadro/pb": "./packages/pb/src/index.ts",
"@nomadro/sdk": "./packages/sdk/src/index.ts",
},
},
webpack: (config) => {
config.resolve.alias = {
...config.resolve.alias,
...aliases,
};
return config;
},
async rewrites() {
return [
{
source: "/vip/ebook/read",
destination: "/vip/ebook-read",
},
{
source: "/vip/ebook/read/:path*",
destination: "/vip/ebook-read",
},
{
source: "/vip/ebook/cloudphone",
destination: "/vip/ebook-cloudphone",
},
{
source: "/api/v1/:path*",
destination: `${API_URL}/api/v1/:path*`,
},
{
source: "/api/social/:path*",
destination: `${SOCIAL_API_URL}/api/social/:path*`,
},
// Planka server API/socket only (UI is native Next from forked client)
{
source: "/work-api",
destination: `${WORK_PLANKA_ORIGIN}/`,
},
{
source: "/work-api/:path*",
destination: `${WORK_PLANKA_ORIGIN}/:path*`,
},
// Etherpad still path-proxied until pad UI is ported
{
source: "/work-mf/etherpad",
destination: `${WORK_ETHERPAD_ORIGIN}/`,
},
{
source: "/work-mf/etherpad/:path*",
destination: `${WORK_ETHERPAD_ORIGIN}/:path*`,
},
];
},
async headers() {
return [
{
source: "/:path*",
headers: [
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
],
},
];
},
};
export default nextConfig;