All Products
Search
Document Center

Edge Security Acceleration:Pages building and routing

Last Updated:Jan 16, 2026

Pages lets you quickly configure build information and customize routing behavior for different scenarios using the esa.jsonc file.

Build Pages with esa.jsonc

Create an esa.jsonc file in the root directory of your project in GitHub. The .jsonc file lets you define and override the project's default settings for more flexible configuration.

Why use it

  • Infrastructure as code: Your configuration is version-controlled with your code, making every change traceable.

  • Easy team collaboration: All team members share the same configuration file, ensuring consistency between local development and cloud Deployments.

  • Convenient rollbacks: You can roll back to any commit, precisely reproducing its build environment.

Configuration priority

Settings in the esa.jsonc file take precedence over settings in the console:

  • If your project does not have an esa.jsonc file:

  • If your project has an esa.jsonc file:

    • The system automatically detects the file and uses it as the sole configuration source.

    • To modify the configuration, edit the esa.jsonc file and push the changes to your GitHub repository.

    • On the project's details page in the console, any settings managed by esa.jsonc are ignored.

Configuration example

Add an esa.jsonc file to your Pages repository in GitHub. Here is an example configuration:

{
  "name": "vite-react-template",
  "entry": "./src/index.js",
  "installCommand": "npm install",
  "buildCommand": "npm run build",
  "assets": {
    "directory": "./dist",
    "notFoundStrategy": "singlePageApplication"
  }
}

Parameter

Description

name

The target project for the deployment. If the project does not exist, a new one is automatically created with this name.

entry

The entrypoint file path for the edge function. Example: ./src/index.ts.

installCommand

Configure a custom installation command, such as npm install. This overwrites the installation command configured in the console. To skip the installation, set the command to an empty string. Supported package managers include npm, pnpm, yarn, cnpm, and bun.

buildCommand

Configure a custom build command, such as npm run build. This command overwrites the build command configuration in the console. To skip the build step, set the command to an empty string.

assets

The static assets hosting feature supports your website's frontend. Configure one asset directory per project. The assets object provides the following options:

  • directory: The directory in the build output to be served as static assets. Examples: ./public./dist, or ./build.

  • notFoundStrategy: Specifies the action to take when a requested path does not match a static asset.

    • singlePageApplication: Serves the index.html file from the static assets directory with a 200 OK status code. Ideal for a Single-Page Application (SPA).

    • 404Page: Serves the 404.html file from the static assets directory with a 404 Not Found status code.

      Note

      If you configure both a function script and the assets.notFoundStrategy option, Navigation requests will not execute the script. A navigation request is a request initiated by the browser when a user directly navigates to a page (for instance, by typing a URL or clicking a link) and is identified by the Sec-Fetch-Mode: navigate request header.

Routing for static assets

After you configure the esa.jsonc file, request URLs are routed to files in the static asset directory based on the following use cases:

Default

If notFoundStrategy is not configured in esa.jsonc, such as:

{
  "name": "vite-react-template",
  "entry": "./src/index.js",
  "assets": {
    "directory": "./dist"
  }
}

ESA routes requests according to the following flow:

image
  1. When a request reaches a point of presence (POP), the system checks for a matching static asset. If it does, the asset is served. If not, the process continues to step 2.

  2. The system checks if an edge function script exists. If it does, the script is executed. If not, it returns a 404 Not Found response.

Single-page application

When you build a single-page application, set notFoundStrategy to singlePageApplication in esa.jsonc, for example:

{
  "name": "vite-react-template",
  "entry": "./src/index.js",
  "assets": {
    "directory": "./dist",
    "notFoundStrategy": "singlePageApplication"
  }
}

ESA routes requests according to the following flow:

image
  1. When a client request URL reaches a POP, the system checks for a corresponding static asset. If a match is found, the static file is returned. If a match is not found, the process continues to step 2.

  2. The system checks if the request is a navigation request (containing the Sec-Fetch-Mode: navigate Request Header). If not, the process continues to step 3. If it is, the request is routed to the /index.html file, and the process continues to step a:

    a. The system checks if an index.html page exists. If it does, it returns the content of /index.html with a 200 OK status. If not, the process continues to step 3.

  3. The system checks if a function script exists. If it does, the script is executed. If not, it returns a 404 Not Found response.

Build a static site

When you build a static site, set notFoundStrategy to 404Page in esa.jsonc, for example:

{
  "name": "vite-react-template",
  "entry": "./src/index.js",
  "assets": {
    "directory": "./dist",
    "notFoundStrategy": "404Page"
  }
}

ESA routes requests according to the following flow:

image
  1. When a client request URL reaches an edge node, the system checks for a corresponding static asset. If a match is found, the static file is returned directly. If a match is not found, the process continues to step 2.

  2. The system checks if the request is a navigation request (containing the Sec-Fetch-Mode: navigate Request Header). If not, the process continues to step 3. If it is, the request is routed to the /index.html file, and the process continues to step a:

    a. The system checks if an index.html page exists. If it does, it returns the content of /index.html with a 200 OK status. If not, the process continues to step 3.

  3. The system checks if a function script exists. If it does, the script is executed. If not, it returns a 404 Not Found response.

Modify basic configuration in the console

  1. Log on to the ESA console. In the left navigation pane, choose Edge Computing > Functions and Pages.

  2. On the Functions and Pages page, find the function that you want to manage, and click the routine name or Actions column's View Details.

  3. Select the Basic Information tab and click Modify for the Build Information.

    image

  4. Change the Build Information as needed.

    image

    Parameter

    Description

    Root Dir

    The build command runs in this directory. Default: /. If you use a monorepo, enter the path of the subproject to build (for example, /frontend or /packages/web).

    Static Asset Dir

    The directory in the build output to be served as static assets. Examples: ./public./dist, or ./build. The assets.directory setting in esa.jsonc has higher priority and will override this setting.

    Function File Path

    The entrypoint file path for the function. Example: ./src/index.ts. The entry setting in esa.jsonc has higher priority and will override this setting.

    Node.js

    The Node.js version used for the build. Trigger a new build for any changes to take effect. You can also specify the major Node.js version in the engines.node field of your package.json file. The package.json setting has higher priority and will override this setting.

    Env Variables

    Set environment variables available during the build. Access them through the global process.env object.