nomadro/next.config.ts
eric 9f8fec1723 Ship portal PC/H5 acceptance, VIP ScrollReader, admin analytics and ops anchors.
Adds /api/health, ntfy notify on config save, /admin/analytics charts, and deploy smoke for miniprogram config/API.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 23:52:00 -05:00

67 lines
1.9 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:8000").replace(
/\/$/,
"",
);
const aliases = {
"@ebook": path.resolve(__dirname, "apps/ebook/src"),
"@community": path.resolve(__dirname, "apps/nomadweb/frontend/src"),
"@navmini": path.resolve(__dirname, "apps/navmini/src"),
"@vip": path.resolve(__dirname, "apps/nomadvip"),
"@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 = {
experimental: {
externalDir: true,
},
transpilePackages: ["@nomadro/pay", "@nomadro/pb", "@nomadro/sdk"],
turbopack: {
resolveAlias: {
"@ebook": "./apps/ebook/src",
"@community": "./apps/nomadweb/frontend/src",
"@navmini": "./apps/navmini/src",
"@vip": "./apps/nomadvip",
"@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 [
// VIP 电子书阅读器:对外 /vip/ebook/read,内部挂载点(避免 ebook 子路由被挡)
{
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",
},
// Community/ebook FastAPI uses /api/v1 — do not steal VIP Next handlers at /api/pay|auth|vip
{
source: "/api/v1/:path*",
destination: `${API_URL}/api/v1/:path*`,
},
];
},
};
export default nextConfig;