1.9 KiB
Cloudflare Pages Deployment Guide
How to create a new project
Fork this project on GitHub, then log in to dash.cloudflare.com and go to Pages.
-
Click "Create a project".
-
Choose "Connect to Git".
-
Connect Cloudflare Pages to your GitHub account.
-
Select the forked project.
-
Click "Begin setup".
-
For "Project name" and "Production branch", use the default values or change them as needed.
-
In "Build Settings", choose the "Framework presets" option and select "Next.js".
-
Do not use the default "Build command" due to a node:buffer bug. Instead, use the following command:
npx @cloudflare/next-on-pages --experimental-minify
-
For "Build output directory", use the default value and do not modify it.
-
Do not modify "Root Directory".
-
For "Environment variables", click ">" and then "Add variable". Fill in the following information:
NODE_VERSION=20.1
NEXT_TELEMETRY_DISABLE=1
OPENAI_API_KEY=your_own_API_key
YARN_VERSION=1.22.19
PHP_VERSION=7.4
Optionally fill in the following based on your needs:
CODE= Optional, access passwords, multiple passwords can be separated by commas
OPENAI_ORG_ID= Optional, specify the organization ID in OpenAI
HIDE_USER_API_KEY=1 Optional, do not allow users to enter their own API key
DISABLE_GPT4=1 Optional, do not allow users to use GPT-4
ENABLE_BALANCE_QUERY=1 Optional, allow users to query balance
DISABLE_FAST_LINK=1 Optional, disable parse settings from url
OPENAI_SB=1 Optional,use the third-party OpenAI-SB API
-
Click "Save and Deploy".
-
Click "Cancel deployment" because you need to fill in Compatibility flags.
-
Go to "Build settings", "Functions", and find "Compatibility flags".
-
Fill in "nodejs_compat" for both "Configure Production compatibility flag" and "Configure Preview compatibility flag".
-
Go to "Deployments" and click "Retry deployment".
-
Enjoy.