This guide helps you smoothly migrate your Cloudflare Pages project to EdgeOne Makers.
Preparations: Search Build Command and Build Output
First, you need to locate the build command and build output for your Cloudflare Pages project:
1. Log in to the dashboard and find the project to migrate.
2. Enter the project's "Settings" tab and view the "Build Configuration" module.
3. Record the values of the "Build command" and "Build output" fields.
Example:
npm run build
Build output: build
This information will be used in project configuration.
2.Configuration Migration: Handle Redirects and Headers
Cloudflare Pages uses _redirects and _headers files to configure redirect rules and custom headers. You need to migrate these configurations to the edgeone.json file in EdgeOne Makers.
Comparison example of both
Cloudflare Pages _redirects file:
/old-path /new-path 301
/api/* /api/proxy 200
Cloudflare Pages _headers file:
/*
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
/assets/*
Cache-Control: public, max-age=31536000
In EdgeOne Makers, create an edgeone.json file to include these configurations:
{
"redirects":[
{
"source":"/old-path",
"destination":"/new-path",
"statusCode":301
}
],
"rewrites":[
{
"source":"/api/*",
"destination":"/api/proxy"
}
],
"headers":[
{
"source":"/*",
"headers":[
{
"key":"X-Frame-Options",
"value":"DENY"
},
{
"key":"X-Content-Type-Options",
"value":"nosniff"
}
]
},
{
"source":"/assets/*",
"headers":[
{
"key":"Cache-Control",
"value":"public, max-age=31536000"
}
]
}
]
}
During migration, the mapping between Cloudflare Pages configuration files and EdgeOne Makers is as follows:
_headers file corresponds to headers configuration.
_redirects file in the file corresponds to redirects configuration.
Proxy rewrite rules (such as /api/*) correspond to rewrites configuration.
3.Function Migration: From Cloudflare Pages to EdgeOne Makers
The two platforms are relatively consistent in syntax and usage.
Here is a simple example:
// Cloudflare Makers Functions
exportfunctiononRequest(context){
returnnewResponse("Hello, Cloudflare Pages!");
}
// EdgeOne Makers Functions
exportfunctiononRequest(context){
returnnewResponse("Hello, EdgeOne Makers!");
}
main similarities
Both platforms use the onRequest function to handle all HTTP methods.
Functions on both platforms receive a context object containing request information and environment variables.
Same response method, both use Response object.
Routing rules are basically the same, supporting file system-based routing and dynamic routing.
Note:
Makers Functions supports both Cloud Functions and Edge Functions. These two have some differences in features, such as the context object. You can choose between them based on your specific requirements.
Migration suggestions: No need to change code writing and calling.
Note: If you need to migrate from Cloudflare Workers to Cloudflare Pages Functions, refer to the documentation. After a successful migration, you can try the migration steps described above. If you still encounter issues, contact us through the community for resolution.
2. Click "Create project" and select your GitHub repository.
3. In the project settings, fill in the build command and build output recorded earlier.
4. Click the "Start Deployment" button, and Makers will automatically build and deploy your project.
5.Domain Configuration: Adding a Custom Domain
migration steps
1. Add your custom domain in project settings and get the CNAME record value.
2. Log in to your DNS provider console (if your domain is managed by Cloudflare, sign in to the Cloudflare console).
3. Find the CNAME record previously set for Cloudflare Pages.
4. Update the CNAME record to point to the new value provided by EdgeOne Makers.
5. If you set up other DNS records (such as A or AAAA records) for Cloudflare Pages earlier, delete these records.
6. Wait for the DNS update to take effect (may take a few minutes to a few hours).
Note: If your domain was previously managed by Cloudflare, you can choose to continue using Cloudflare's DNS service, just update the corresponding CNAME record.
By completing the steps above, you have successfully migrated your Cloudflare Pages project to EdgeOne Makers. The two platforms share some similarities. However, based on our robust infrastructure, we have optimized Makers with features like intelligent refresh and pre-warming tailored to its product characteristics, delivering an out-of-the-box experience. Furthermore, during the public beta, Makers imposes fewer restrictions compared to competitors, offering developers greater flexibility and more choices. For customer support, we provide more responsive assistance and are committed to creating a superior product experience for developers.
If you encounter any issues during the migration, refer to the EdgeOne Makers official documentation.