Edge Developer Platform
  • Pages
    • Product Introduction
    • Quick Start
      • Importing a Git Repository
      • Starting From a Template
      • Direct Upload
      • Start with AI
    • Framework Guide
      • Frontends
      • Backends
      • Full-stack
        • Next.js
    • Project Guide
      • Project Management
      • edgeone.json
      • Configuring Cache
      • Error Codes
    • Build Guide
    • Deployment Guide
      • Overview
      • Create Deploys
      • Manage Deploys
      • Deploy Button
      • Using Github Actions
      • Using CNB Plugin
      • Using IDE PlugIn
      • Using CodeBuddy IDE
    • Domain Management
      • Overview
      • Custom Domain
      • Configuring an HTTPS Certificate
      • How to Configure a DNS CNAME Record
    • Pages Functions
      • Overview
      • Edge Functions
      • Node Functions
    • Log Analysis
    • KV Storage
    • Edge AI
    • API Token
    • EdgeOne CLI
    • Pages MCP
    • Integration Guide
      • AI
        • Dialogue Large Models Integration
        • Large Models for Images Integration
      • Database
        • Supabase Integration
        • Pages KV Integration
      • Ecommerce
        • Shopify Integration
        • WooCommerce Integration
      • Payment
        • Stripe Integration
        • Integrating Paddle
      • CMS
        • WordPress Integration
        • Contentful Integration
        • Sanity Integration
      • Authentication
        • Supabase Integration
        • Clerk Integration
    • Best Practices
      • Using General Large Model to Quickly Build AI Application
      • Use the Deepseek-R1 model to quickly build a conversational AI site
      • Building an Ecommerce Platform with WordPress + WooCommerce and GatsbyJS
      • Building a SaaS Site Using Supabase and Stripe
      • Building a Company Brand Site Quickly
      • How to Quickly Build a Blog Site
    • Migration Guides
      • Migrating from Vercel to EdgeOne Pages
      • Migrating from Cloudflare Pages to EdgeOne Pages
      • Migrating from Netlify to EdgeOne Pages
    • Troubleshooting
    • FAQs
    • Contact Us
    • Release Notes

edgeone.json

In addition to performing project settings on the console, you can also create an edgeone.json file in the project root directory to define and override the default behavior of the project, so that you can configure the project more flexibly.

The configuration file includes the following settings:

buildCommand

Override the build command in Console - Project Setting - Build Deployment Configuration.
{
"buildCommand": "next build"
}


installCommand

Override the installation command in Console - Project Setting - Build Deployment Configuration. This configuration allows customizing the package manager used in the build process.
{
"installCommand": "npm install"
}


outputDirectory

Override the output directory in Console - Project Setting - Build Deployment Configuration.
{
"outputDirectory": "./build"
}


nodeVersion

Specify the node Version for the build environment. Recommend using the pre-installed versions 14.21.3, 16.20.2, 18.20.4, 20.18.0, or 22.11.0. Using other versions may cause deployment failure.
{
"nodeVersion": "22.11.0"
}


redirects

Redirect a request from one URL to another URL. The following is examples of redirection.

Use a 301 permanent redirect to redirect requests from the URL /articles/+ ID (such as /articles/123) to the URL /news-articles/ + ID (such as /news-articles/123):
{
"redirects": [
{
"source": "/articles/:id",
"destination": "/news-articles/:id",
"statusCode": 301
}
]
}

Use a 302 temporary redirect to redirect requests from /old-path to /new-path:
{
"redirects": [
{
"source": "/old-path",
"destination": "/new-path",
"statusCode": 302
}
]
}

Use a 301 permanent redirect to redirect requests from /template-source to the absolute path of the external site https://github.com/TencentEdgeOne/pages-templates/tree/main/examples/chrome-ai:
{
"redirects": [
{
"source": "/template-source",
"destination": "https://github.com/TencentEdgeOne/pages-templates/tree/main/examples/chrome-ai",
"statusCode": 301
}
]
}

Use a 301 permanent redirect to redirect non-www requests to www, and also support reverse redirect (only applicable to custom domain name):
{
"redirects": [
{
"source": "$host",
"destination": "$wwwhost",
"statusCode": 301
}
]
}
Note:
Maximum number of redirects is limited to 30
source and destination must not exceed 500 characters


rewrites

Rewrite all requests starting with /assets/ to the /assets-new/ directory, retaining the path section of the original request.
{
"rewrites": [
{
"source": "/assets/*",
"destination": "/assets-new/:splat"
}
]
}

Further refine rewrite rules, targeting PNG image files. The following example will ensure ALL requests ending with .png are rewritten to the new path while retaining the filename.
{
"rewrites": [
{
"source": "/assets/*.png",
"destination": "/assets-new/:splat.png"
}
]
}
Note:
Maximum number of rewrites is limited to 30
source and destination must not exceed 500 characters
This configuration is applicable only to static resource access
- Frontend route rewriting is not supported for SPAs (single-page applications)
Source path must start with `/`

SPA application rewriting advice
Note: If needed, implement URL rewriting in SPA with the following solution:
Warning: Frontend route redirection
Use the built-in routing system of the framework to perform path redirection
Define rewrite rules in the routing configuration


headers

Customize and manage HTTP response headers to improve website performance and security while enhancing user experience.

Enhance website security by setting the X-Frame-Options header for all requests to prevent clickjacking attacks. Meanwhile, specify a 2-hour cache for responses via Cache-Control to improve performance and reduce server burden.
{
"headers": [
{
"source": "/*",
"headers": [
{
"key": "X-Frame-Options",
"value": "DENY"
},
{
"key": "Cache-Control",
"value": "max-age=7200"
}
]
}
]
}

Further optimize the cache policy for specific resources, targeting static resources under the /assets/ directory. This example will set a longer cache time for all files in this directory.
{
"headers": [
{
"source": "/assets/*",
"headers": [
{
"key": "Cache-Control",
"value": "s-maxage=10000, max-age=31536000"
},
{
"key": "Pages-Cache-Control",
"value": "s-maxage=10000"
}
]
}
]
}
Note:
Maximum number of headers is limited to 30
The key of each header is limited to 1-100 characters, and numbers, letters, and special symbols '-' are allowed.
The value of each header is limited to 1-1000 characters. Chinese characters are not allowed.


caches

Configure edge cache time for different resources, optimize edge cache policies for different resources, and enhance the loading speed of requested resources.

Set all files in the images directory to cache for 1 day.
"caches": [
{
"source": "/images/*",
"cacheTtl": 86400
}
]

Set cache for specific files. This example sets the sitemap.xml file to no-cache and all jpg files under images to cache for 1 hr.
"caches": [
{
"source": "/sitemap.xml",
"cacheTtl": 0
},
{
"source": "/images/*.jpg",
"cacheTtl": 3600
}
]
Note:
cacheTtl is in seconds, cannot be less than 0 and does not allow decimals. Set to 0 for no-cache.


Source Match Rule Description

When configuring redirects, rewrites, headers, and caches, the source field is for defining the request path match rule. The following is the main matching feature:

1.Path matching
The source field supports the use of specific modes to match request paths. The match rule parses based on the request URL.

2.Wildcards
Use an asterisk (*) as a wildcard to match any character in the path. Please note, the source can only contain one wildcard.

3.Placeholder
A placeholder starts with a colon (:) followed by the placeholder name. Each placeholder can only be used once in the source and will match all characters except the separator.

Note:
Note: For details on custom configuration usage, see Glthub TencentEdgeOne.


Edgeone.Json File Example

The following example shows how to combine multiple settings in a configuration file, including but not limited to all available options. Please note that each setting item in the file is optional.
{
"name": "example-app",
"buildCommand": "next build",
"installCommand": "npm install",
"outputDirectory": "./build",
"nodeVersion": "22.11.0",
"redirects": [
{
"source": "/articles/:id",
"destination": "/news-articles/:id",
"statusCode": 301
},
{
"source": "/old-path",
"destination": "/new-path",
"statusCode": 302
}
],
"rewrites": [
{
"source": "/assets/*",
"destination": "/assets-new/:splat"
}
],
"headers": [
{
"source": "/*",
"headers": [
{
"key": "X-Frame-Options",
"value": "DENY"
},
{
"key": "Cache-Control",
"value": "max-age=7200"
}
]
},
{
"source": "/assets/*",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=31536000"
}
]
}
]
}