Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Writes edge middleware for EdgeOne Makers projects to intercept requests, handle redirects, rewrites, auth guards, and headers.
32% 100%+68 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 7 of 22 without it.
3 of 3 safety checks passed
Not used yet
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.tswithNextRequest/NextResponse). The patterns below are for non-framework or pure static projects only.
File: middleware.js (project root)
export function middleware(context) {
const { request, next, redirect, rewrite } = context;
// Pass through — no modification
return next();
}
| 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 |
By default middleware runs on ALL routes. Use config.matcher to limit scope:
// Only run on /api/* routes
export const config = {
matcher: ['/api/:path*'],
};
Next to this one in the catalogue, plus more from the same author.