Skip to content

Commit 4212539

Browse files
committed
fix: 解决cloudflare报错
1 parent c1c9a9f commit 4212539

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.next
22
node_modules
3+
.vercel

next.config.mjs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
import { setupDevPlatform } from '@cloudflare/next-on-pages/next-dev';
12
import nextra from 'nextra';
23

34
const withNextra = nextra({
45
// ... Other Nextra config options
56
});
67

8+
// eslint-disable-next-line n/prefer-global/process
9+
if (process.env.NODE_ENV === 'development') {
10+
await setupDevPlatform();
11+
}
12+
713
// You can include other Next.js configuration options here, in addition to Nextra settings:
814
export default withNextra({
915
typescript: {
@@ -24,7 +30,7 @@ export default withNextra({
2430
});
2531

2632
config.cache = false; // 关闭缓存
27-
33+
2834
return config;
2935
}
3036
});

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
"keywords": [],
88
"scripts": {
99
"build": "next build --no-lint",
10-
"cf-deploy": "npx @cloudflare/next-on-pages deploy",
11-
"deploy": "pnpm run build && pnpm run cf-deploy",
10+
"deploy": "pnpm run pages:build && wrangler pages deploy",
1211
"dev": "next dev",
1312
"lint": "next lint . --fix",
13+
"pages:build": "npx @cloudflare/next-on-pages",
14+
"preview": "pnpm run pages:build && wrangler pages dev",
1415
"start": "next start"
1516
},
1617
"dependencies": {

pnpm-lock.yaml

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wrandler.jsonc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "my-app",
3+
"compatibility_date": "2025-03-22",
4+
"compatibility_flags": ["nodejs_compat"],
5+
"pages_build_output_dir": ".vercel/output/static"
6+
}

0 commit comments

Comments
 (0)