Files
谢宇宁andClaude Opus 5.5 61d0a11dfa Initial commit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:51:31 +07:00

94 lines
4.1 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 process from "node:process";
import type { NextConfig } from "next";
/** 本地调试代理目标,见 config/*.env / .env.local 的 API_PROXY_TARGET */
const apiProxyTarget = (process.env.API_PROXY_TARGET || "").replace(/\/$/, "");
const appEnv = process.env.APP_ENV;
const nextConfig: NextConfig = {
output: "standalone",
// 仅在显式 APP_ENV=test|development 时分目录;未设置 / production 仍用 .next
distDir:
appEnv === "test" ? ".next-test" : appEnv === "development" ? ".next-dev" : ".next",
poweredByHeader: false,
cacheComponents: true,
partialPrefetching: true,
turbopack: {
rules: {
"*.css": {
loaders: ["@tailwindcss/turbopack"],
as: "*.css",
},
},
},
async headers() {
const xml = [{ key: "Content-Type", value: "application/xml; charset=utf-8" }];
const xsl = [{ key: "Content-Type", value: "text/xsl; charset=utf-8" }];
return [
{ source: "/sitemap.xml", headers: xml },
{ source: "/sitemaps/:file", headers: xml },
{ source: "/static/sitemapindex.xsl", headers: xsl },
{ source: "/static/sitemap.xsl", headers: xsl },
];
},
async redirects() {
// 枢纽入口 / 旧中文排序段 → 英文规范 URL
return [
{ source: "/short-drama", destination: "/short-drama/hot", permanent: true },
{ source: "/video", destination: "/video/hot", permanent: true },
{ source: "/short-drama/热度优先", destination: "/short-drama/hot", permanent: true },
{ source: "/short-drama/热度优先/:path*", destination: "/short-drama/hot/:path*", permanent: true },
{ source: "/short-drama/最近更新", destination: "/short-drama/latest", permanent: true },
{ source: "/short-drama/最近更新/:path*", destination: "/short-drama/latest/:path*", permanent: true },
{ source: "/video/热度优先", destination: "/video/hot", permanent: true },
{ source: "/video/热度优先/:path*", destination: "/video/hot/:path*", permanent: true },
{ source: "/video/最近更新", destination: "/video/latest", permanent: true },
{ source: "/video/最近更新/:path*", destination: "/video/latest/:path*", permanent: true },
{ source: "/ranking", destination: "/ranking/drama", permanent: true },
{ source: "/ranking/短剧", destination: "/ranking/drama", permanent: true },
{ source: "/ranking/短剧/:path*", destination: "/ranking/drama/:path*", permanent: true },
{ source: "/ranking/视频", destination: "/ranking/video", permanent: true },
{ source: "/ranking/视频/:path*", destination: "/ranking/video/:path*", permanent: true },
// 专题排序段:中文 → 英文
{ source: "/topic/:kind/:key/编辑排序", destination: "/topic/:kind/:key/editorial", permanent: true },
{ source: "/topic/:kind/:key/编辑排序/:page", destination: "/topic/:kind/:key/editorial/:page", permanent: true },
{ source: "/topic/:kind/:key/最新", destination: "/topic/:kind/:key/latest", permanent: true },
{ source: "/topic/:kind/:key/最新/:page", destination: "/topic/:kind/:key/latest/:page", permanent: true },
{ source: "/topic/:kind/:key/最热", destination: "/topic/:kind/:key/hot", permanent: true },
{ source: "/topic/:kind/:key/最热/:page", destination: "/topic/:kind/:key/hot/:page", permanent: true },
];
},
async rewrites() {
if (!apiProxyTarget) return [];
return [
{
source: "/api/:path*",
destination: `${apiProxyTarget}/api/:path*`,
},
// 加密 HLS:相对路径经同域代理(对齐 hkdj-web / 1045)
{
source: "/h5/m3u8/:path*",
destination: `${apiProxyTarget}/h5/m3u8/:path*`,
},
{
source: "/enkey",
destination: `${apiProxyTarget}/enkey`,
},
{
source: "/enkey/:path*",
destination: `${apiProxyTarget}/enkey/:path*`,
},
{
source: "/newenkey",
destination: `${apiProxyTarget}/newenkey`,
},
{
source: "/newenkey/:path*",
destination: `${apiProxyTarget}/newenkey/:path*`,
},
];
},
};
export default nextConfig;