Skip to content

Commit 38fe8e0

Browse files
committed
fix cloudflare pages direct upload build
1 parent e73416d commit 38fe8e0

4 files changed

Lines changed: 10646 additions & 5531 deletions

File tree

README.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,9 +768,19 @@ npm start
768768
1. **只从本地工作副本部署**:不要使用 GitHub 一键导入、Fork 后导入、Connect GitHub 读取仓库等流程。
769769
2. **Vercel**:使用本地 CLI 部署现有项目,参考官方文档:[Import an existing project](https://vercel.com/docs/getting-started-with-vercel/import)
770770
3. **Cloudflare**:使用官方 **Direct Upload** 或 CLI 工作流,不要使用 Git integration,参考官方文档:[Getting started with Pages](https://developers.cloudflare.com/pages/get-started)
771-
4. **Cloudflare 构建参数**:本仓库保留了 `npm run pages:build``wrangler.toml`,可继续用于现有 Cloudflare 构建链路。
772-
5. **功能限制**:托管平台会自动禁用外部媒体代理和 IPTV 流中继;请仅使用允许浏览器直连、允许当前来源访问且具备合法授权的内容源。
773-
6. **如果你需要完整能力**:直接改用 Docker 或传统 Node.js 自托管,不要在托管平台上强行恢复这些能力。
771+
4. **Cloudflare Direct Upload 正确流程**
772+
```bash
773+
npm install
774+
npm run pages:build
775+
```
776+
构建完成后,上传 **`.vercel/output/static`** 目录,而不是仓库根目录、`.next` 目录或源码文件。上传仓库根目录只会把源码当静态文件托管,根路径没有构建产物可供 Pages 入口加载,结果就是 404。
777+
5. **Cloudflare CLI 发布**:如果你使用 CLI,请发布同一个构建产物目录:
778+
```bash
779+
npx wrangler pages deploy .vercel/output/static
780+
```
781+
6. **Cloudflare 构建链路**`npm run pages:build` 现在固定使用仓库内安装的 `next-on-pages` 和兼容版本的 `vercel`,避免构建时临时拉取不受控版本。`wrangler.toml` 继续提供 `nodejs_compat` 兼容标志。
782+
7. **功能限制**:托管平台会自动禁用外部媒体代理和 IPTV 流中继;请仅使用允许浏览器直连、允许当前来源访问且具备合法授权的内容源。
783+
8. **如果你需要完整能力**:直接改用 Docker 或传统 Node.js 自托管,不要在托管平台上强行恢复这些能力。
774784

775785
#### 选项 4:Android TV APK 构建
776786

@@ -864,7 +874,14 @@ npm start
864874

865875
### Cloudflare 托管部署
866876

867-
请在本地工作副本完成更新后,使用 Direct Upload 或 CLI 重新发布。不要使用 Git integration 直接读取 GitHub 仓库。
877+
请在本地工作副本完成更新后,重新执行:
878+
879+
```bash
880+
npm install
881+
npm run pages:build
882+
```
883+
884+
然后使用 Direct Upload 或 CLI 发布 **`.vercel/output/static`**。不要上传仓库根目录,也不要上传 `.next`,否则 Pages 只会托管源码文件,访问站点时直接 404。
868885

869886
### Docker 部署
870887

@@ -900,6 +917,27 @@ npm start
900917

901918
这是 Cloudflare 的临时服务端错误,与代码无关。请在 Deployments 列表中重试部署即可。项目已内置 `wrangler.toml` 配置 `nodejs_compat` 兼容性标志。
902919

920+
### Cloudflare Pages Direct Upload 部署后打开是 404
921+
922+
这通常不是应用路由问题,而是上传了错误的目录。Cloudflare Pages 的 Direct Upload 需要上传已经构建完成的产物目录。
923+
924+
正确做法:
925+
926+
```bash
927+
npm install
928+
npm run pages:build
929+
```
930+
931+
然后上传 **`.vercel/output/static`**
932+
933+
错误做法:
934+
935+
- 上传仓库根目录
936+
- 上传 `.next`
937+
- 直接把源码压缩包丢给 Direct Upload
938+
939+
这些做法都不会生成 Pages 可执行入口,部署成功后打开站点就会是 404。
940+
903941
### IPv6 环境下 HTTPS 访问视频无法播放
904942

905943
如果你的网络使用 IPv6 访问,且通过路由器端口映射(如 20443 → 443),请确保:

app/layout.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import type { Metadata } from "next";
3-
import { Geist, Geist_Mono } from "next/font/google";
43
import "./globals.css";
54
import { ThemeProvider } from "@/components/ThemeProvider";
65
import { AutoSync } from '@/components/AutoSync'; // <-- 引入了自动同步组件
@@ -62,16 +61,6 @@ async function AdKeywordsWrapper() {
6261
return <AdKeywordsInjector keywords={keywords} />;
6362
}
6463

65-
const geistSans = Geist({
66-
variable: "--font-geist-sans",
67-
subsets: ["latin"],
68-
});
69-
70-
const geistMono = Geist_Mono({
71-
variable: "--font-geist-mono",
72-
subsets: ["latin"],
73-
});
74-
7564
export const metadata: Metadata = {
7665
title: siteConfig.title,
7766
description: siteConfig.description,
@@ -107,7 +96,7 @@ export default function RootLayout({
10796
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
10897
</head>
10998
<body
110-
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
99+
className="antialiased"
111100
suppressHydrationWarning
112101
>
113102
<ThemeProvider>

0 commit comments

Comments
 (0)