/makers-middleware
Edge middleware for EdgeOne Makers — request interception, redirects, rewrites, auth guards, A/B testing, and header injection at the edge (V8 runtime).
$ npx -y skills add tencentedgeone/edgeone-pages-skills --skill makers-middleware --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/makers-middleware
Context preview
The summary Claude sees to decide when to auto-load this skill.
Edge middleware for EdgeOne Makers — request interception, redirects, rewrites, auth guards, A/B testing, and header injection at the edge (V8 runtime).
SKILL.md
makers-middleware.SKILL.mdname: edgeone-makers-middleware
description: >-
Edge middleware for EdgeOne Makers — request interception, redirects, rewrites,
auth guards, A/B testing, and header injection at the edge (V8 runtime).
metadata:
author: edgeone
version: "1.0.0"
Middleware
Lightweight request interception running at the edge (V8 runtime). Use for redirects, rewrites, auth guards, A/B testing, and header injection.
> ⚠️ **Framework projects (Next.js, Nuxt, etc.)**: Do NOT use this platform middleware format. Use the framework's built-in middleware instead (e.g. Next.js `middleware.ts` with `NextRequest`/`NextResponse`). The patterns below are for non-framework or pure static projects only.
Basic middleware
File: `middleware.js` (project root)
export function middleware(context) {
const { request, next, redirect, rewrite } = context;
// Pass through — no modification
return next();
}Context API
| Property | Type | Description | |----------|------|-------------| | `request` | `Request` | Current request object | | `next(options?)` | `Function` | Continue to origin; optionally modify headers | | `redirect(url, status?)` | `Function` | Redirect (default 307) | | `rewrite(url)` | `Function` | Rewrite request path (transparent to client) | | `geo` | `GeoProperties` | Client geolocation | | `clientIp` | `string` | Client IP address |
Route matching
By default middleware runs on ALL routes. Use `config.matcher` to limit scope:
// Only run on /api/* routes
export const config = {
matcher: ['/api/:path*'],
};
export function middleware(context) {
// Auth check for API routes only
const token = context.request.headers.get('Authorization');
if (!token) {
return new Response('Unauthorized', { status: 401 });
}
return context.next();
}**Matcher patterns:**
// Single path
export const config = { matcher: '/about' };
// Multiple paths
export const config = { matcher: ['/api/:path*', '/admin/:path*'] };
// Regex
export const config = { matcher: ['/api/.*', '^/user/\\d+$'] };Common patterns
URL Redirect
export function middleware(context) {
const url = new URL(context.request.url);
if (url.pathname === '/old-page') {
return context.redirect('/new-page', 301);
}
return context.next();
}URL Rewrite (transparent proxy)
export function middleware(context) {
const url = new URL(context.request.url);
if (url.pathname.startsWith('/blog')) {
return context.rewrite('/content' + url.pathname);
}
return context.next();
}Add request headers
export function middleware(context) {
return context.next({
headers: {
'x-request-id': crypto.randomUUID(),
'x-client-ip': context.clientIp,
'x-country': context.geo.countryCodeAlpha2,
},
});
}Auth guard
export const config = {
matcher: ['/api/:path*', '/admin/:path*'],
};
export function middleware(context) {
const token = context.request.headers.get('Authorization');
if (!token || !token.startsWith('Bearer ')) {
return new Response(JSON.stringify({ error: 'Unauthorized' }), {
status: 401,
headers: { 'Content-Type': 'application/json' },
});
}
return context.next();
}Geo-based routing
export function middleware(context) {
const country = context.geo.countryCodeAlpha2;
if (country === 'CN') {
return context.rewrite('/zh' + new URL(context.request.url).pathname);
}
return context.next();
}A/B Testing
export function middleware(context) {
const url = new URL(context.request.url);
if (url.pathname === '/landing') {
const variant = Math.random() < 0.5 ? '/landing-a' : '/landing-b';
return context.rewrite(variant);
}
return context.next();
}Direct JSON response
export function middleware(context) {
const url = new URL(context.request.url);
if (url.pathname === '/api/health') {
return new Response(JSON.stringify({ status: 'ok', timestamp: Date.now() }), {
headers: { 'Content-Type': 'application/json' },
});
}
return context.next();
}GeoProperties
Available on `context.geo`:
| Property | Type | Example | |----------|------|---------| | `countryName` | string | Singapore | | `countryCodeAlpha2` | string | SG | | `countryCodeAlpha3` | string | SGP | | `regionName` | string | — | | `cityName` | string | Singapore | | `latitude` | number | 1.29027 | | `longitude` | number | 103.851959 | | `asn` | number | 132203 |
Read more
name: edgeone-makers-middleware description: >- Edge middleware for EdgeOne Makers — request interception, redirects, rewrites, auth guards, A/B testing, and header injection at the edge (V8 runtime). metadata: author: edgeone version: "1.0.0"
Middleware
Lightweight request interception running at the edge (V8 runtime). Use for redirects, rewrites, auth guards, A/B testing, and header injection.
> ⚠️ **Framework projects (Next.js, Nuxt, etc.)**: Do NOT use this platform middleware format. Use the framework's built-in middleware instead (e.g. Next.js `middleware.ts` with `NextRequest`/`NextResponse`). The patterns below are for non-framework or pure static projects only.
Basic middleware
File: `middleware.js` (project root)
export function middleware(context) {
const { request, next, redirect, rewrite } = context;
// Pass through — no modification
return next();
}Context API
| Property | Type | Description | |----------|------|-------------| | `request` | `Request` | Current request object | | `next(options?)` | `Function` | Continue to origin; optionally modify headers | | `redirect(url, status?)` | `Function` | Redirect (default 307) | | `rewrite(url)` | `Function` | Rewrite request path (transparent to client) | | `geo` | `GeoProperties` | Client geolocation | | `clientIp` | `string` | Client IP address |
Route matching
By default middleware runs on ALL routes. Use `config.matcher` to limit scope:
// Only run on /api/* routes
export const config = {
matcher: ['/api/:path*'],
};
export function middleware(context) {
// Auth check for API routes only
const token = context.request.headers.get('Authorization');
if (!token) {
return new Response('Unauthorized', { status: 401 });
}
return context.next();
}**Matcher patterns:**
// Single path
export const config = { matcher: '/about' };
// Multiple paths
export const config = { matcher: ['/api/:path*', '/admin/:path*'] };
// Regex
export const config = { matcher: ['/api/.*', '^/user/\\d+$'] };Common patterns
URL Redirect
export function middleware(context) {
const url = new URL(context.request.url);
if (url.pathname === '/old-page') {
return context.redirect('/new-page', 301);
}
return context.next();
}URL Rewrite (transparent proxy)
export function middleware(context) {
const url = new URL(context.request.url);
if (url.pathname.startsWith('/blog')) {
return context.rewrite('/content' + url.pathname);
}
return context.next();
}Add request headers
export function middleware(context) {
return context.next({
headers: {
'x-request-id': crypto.randomUUID(),
'x-client-ip': context.clientIp,
'x-country': context.geo.countryCodeAlpha2,
},
});
}Auth guard
export const config = {
matcher: ['/api/:path*', '/admin/:path*'],
};
export function middleware(context) {
const token = context.request.headers.get('Authorization');
if (!token || !token.startsWith('Bearer ')) {
return new Response(JSON.stringify({ error: 'Unauthorized' }), {
status: 401,
headers: { 'Content-Type': 'application/json' },
});
}
return context.next();
}Geo-based routing
export function middleware(context) {
const country = context.geo.countryCodeAlpha2;
if (country === 'CN') {
return context.rewrite('/zh' + new URL(context.request.url).pathname);
}
return context.next();
}A/B Testing
export function middleware(context) {
const url = new URL(context.request.url);
if (url.pathname === '/landing') {
const variant = Math.random() < 0.5 ? '/landing-a' : '/landing-b';
return context.rewrite(variant);
}
return context.next();
}Direct JSON response
export function middleware(context) {
const url = new URL(context.request.url);
if (url.pathname === '/api/health') {
return new Response(JSON.stringify({ status: 'ok', timestamp: Date.now() }), {
headers: { 'Content-Type': 'application/json' },
});
}
return context.next();
}GeoProperties
Available on `context.geo`:
| Property | Type | Example | |----------|------|---------| | `countryName` | string | Singapore | | `countryCodeAlpha2` | string | SG | | `countryCodeAlpha3` | string | SGP | | `regionName` | string | — | | `cityName` | string | Singapore | | `latitude` | number | 1.29027 | | `longitude` | number | 103.851959 | | `asn` | number | 132203 |
Official AI Agent Skills for developing and deploying projects on EdgeOne Makers.
Repo: tencentedgeone/edgeone-pages-skills
Other skills on edgeone-makers-tools.
- /makers-agents
This skill guides building AI agent endpoints on EdgeOne Makers — five framework routes (DeepAgents, LangGraph, CrewAI, OpenAI Agents SDK, Claude Agent SDK), platform-injected `context.store` / `context.tools` / `context.sandbox`, conversation_id dual-channel routing, SSE
Open skill - /makers-cli
EdgeOne Makers CLI command reference. Use when running edgeone CLI commands for dev, build, deploy, env management.
Open skill - /makers-cloud-functions
EdgeOne Makers Cloud Functions — Node.js, Go, and Python runtimes. Use when building server-side APIs, Express/Koa patterns, or backend logic.
Open skill - /makers-deploy
This skill deploys frontend and full-stack projects to EdgeOne Makers (Tencent EdgeOne). Trigger this skill whenever deployment is part of the task — whether as the primary intent or a secondary step. Examples: "deploy my app", "publish this site", "push this live", "create a
Open skill - /makers-edge-functions
V8-based lightweight edge functions on EdgeOne Makers. Covers routing, KV storage access, request/response handling, and environment variables at the edge.
Open skill - /makers-env-adaption
Environment-specific adaptation rules for EdgeOne Makers Skills running in sandboxed or restricted AI coding environments (e.g. WorkBuddy). Trigger when: the user is working in WorkBuddy, a sandboxed IDE, or any non-interactive/CI environment where CLI commands may hang or
Open skill

