二叉树树

二叉树树

瞎几吧写

Teach you how to deploy the AList frontend to CF Pages! Make your AList load in seconds!

Summary#

This tutorial is not a serverless deployment of AList, but rather deploys the front-end page to Cloudflare Pages, allowing users to quickly pull front-end files from Cloudflare's edge nodes without going back to the origin, improving the browsing experience. The back-end still requires a server exposed to the public network to deploy AList (if there is no public server, Cloudflare Tunnels can be used).

First, ensure your back-end server supports dual-stack access (IPv4 and IPv6)#

  1. Use Cloudflare Tunnel to tunnel through Cloudflare.

  2. Set up A and AAAA records separately; it's troublesome. If your IP is fast, you might not need to separate the front and back ends. Exposing the origin's front and back ends cannot avoid DDoS attacks because your origin will be exposed in the HTTP message.

Then, officially deploy the AList front-end to Cloudflare Pages#

  1. Fork the repository:
  1. Change the env.production file in the project root directory to your back-end server address

424a1a2f76edc52dd95a3f7924417d83

  1. Clone the repository to your local machine; you need to install Git:
Using SSH (you need to hold your Github SSH private key):
git clone git@github.com:your_username/your_forked_repository

Using HTTPS (there's a chance of SSL handshake failure in China):
git clone git@github.com:your_username/your_forked_repository
  1. Download the localization package: AcoFork's cloud storage or Crowdin - login required
    9ba7aa1a74a16f6d36d8980fde015afe

  2. Unzip it, and copy the Zh-CN folder from alist (zh-CN)\src\lang to src/lang under the repository.

  3. Edit the .gitignore in the root directory, adding a line !/src/lang/zh-CN/ to ensure the files are not ignored.

  4. Download Node.js. Open a terminal in the root directory to generate the files needed for Chinese:

Install cnpm:
npm install -g cnpm --registry=https://registry.npmmirror.com

Install dependencies:
cnpm install --legacy-peer-deps

Generate files needed for Chinese:
node .\scripts\i18n.mjs
  1. Stage the changes and commit to the remote repository; open a terminal in the root directory.
git add .   //Stage the changes
git commit -m Add Chinese   //Commit the changes
git push -f   //Force push the changes to the remote repository
  1. Go to the Cloudflare Dashboard, and navigate to the Workers and Pages page

caf5ecd7a74ddba4fd942fb3ae10ba3d

  1. Create a Pages, and choose to connect to a Git repository

2d7bf36b759a97e67e56d052b5a6d4ce

  1. Select your repository and start the setup

d80fed72915e81c7a73dac5bde7f1f79

  1. Enter the build command: pnpm install && pnpm build, and choose the build output directory as /dist

b20b09629c6b7a37df858b830124eba6

  1. Wait for Cloudflare to finish building, and bind a custom domain to Pages
    ac186b18ebd6817268ffd61ca84cf842
  2. Visit the custom domain to check if AList is functioning properly

16ed1a6d31f8bf143e7f8ecc61c59126

Customizing AList#

We all know that AList supports custom headers and content, but since Cloudflare Pages is a static page, we adopt a hard-coded method to directly write the content that needs to be customized into the index.html in the root directory.
169353a448f588c35afb6dcfb61b5929

  1. Edit the index.html in the root directory.
  2. Stage the changes and commit to the remote repository; open a terminal in the root directory.
git add .   //Stage the changes
git commit -m Your commit summary   //Commit the changes
git push -f   //Force push the changes to the remote repository
  1. Cloudflare Pages will automatically rebuild; wait for the new webpage to finish building.

73aac2c2d49d8e795fa1c77eebfbbaf2

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.