Drop-in middleware for Cloudflare, Vercel, Next.js, and Express. Detects AI-agent visits, logs them, and (next week) serves them enhanced HTML — while humans and Googlebot see your site exactly as before.
Right after install, every GPTBot / ClaudeBot / PerplexityBot visit lands in your bot_visits dashboard with timestamp, path, and bot key. No other behavior changes — your site responds exactly as before.
When MentionFox flips FOXEDGE_WIRE_ENABLED for your domain, the same middleware automatically starts serving rewritten HTML to AI agents — better citations, cleaner schema, more accurate facts. No re-install, no code change. Humans still see your unchanged site.
Best if your DNS is on Cloudflare. The worker sits in front of your origin globally; rollback is one click (delete the route).
Cloudflare dashboard → Workers & Pages → Create application → Create Worker. Name it foxedge-mentionfox. Replace the default code with the snippet below.
// Download the full file at: // https://mentionfox.com/foxedge/cloudflare-worker.js // // Or run: // curl https://mentionfox.com/foxedge/cloudflare-worker.js -o worker.js // // Then paste the file's contents into your Cloudflare Worker editor. // // Detects 20 LLM-bot User-Agents (GPTBot, ClaudeBot, PerplexityBot, // Google-Extended, Bytespider, etc.). Logs visits to bot_visits. // Phase 2 wire-up is automatic when MentionFox enables it for your // domain. No re-install needed.
Workers & Pages → foxedge-mentionfox → Settings → Variables and Secrets. Add a Secret named BOTSIGHT_TOKEN. Paste your token from the FoxEdge dashboard.
Workers & Pages → foxedge-mentionfox → Triggers → Routes. Add yourdomain.com/* (or *yourdomain.com/* for all subdomains).
curl -A "GPTBot/1.0" -I https://yourdomain.com/ # Look for: x-edgeoptimize-request-id and x-edgeoptimize-bot-detected: 1 curl -A "Mozilla/5.0" -I https://yourdomain.com/ # Those headers should NOT appear — humans pass through unchanged.
For Vercel deployments without Next.js (Vite, Astro, plain static, SvelteKit). Same logic as the Cloudflare Worker, runs in Vercel Edge Runtime.
Save the file at your project root. If you already have a middleware.ts, see chaining instructions in the file header — do NOT overwrite.
// Download the full file at: // https://mentionfox.com/foxedge/vercel-middleware.ts // // Save as middleware.ts at your project root (NOT inside pages/ or app/). // // Same LLM allowlist as the Cloudflare worker. Reads BOTSIGHT_TOKEN // from process.env. Includes a runFoxEdge() helper for chaining // with an existing middleware.ts.
Vercel dashboard → your project → Settings → Environment Variables. Add BOTSIGHT_TOKEN for Production and Preview.
curl -A "GPTBot/1.0" -I https://yourdomain.com/ # Look for: x-edgeoptimize-request-id and x-edgeoptimize-bot-detected: 1
npm package with auto-composing middleware.ts and an optional withFoxEdge() wrapper for next.config.js.
npm install @mentionfox/foxedge-middleware
At your project root (sibling of next.config.js):
import { foxEdgeMiddleware } from '@mentionfox/foxedge-middleware/next';
export const config = {
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
};
export default foxEdgeMiddleware({
token: process.env.BOTSIGHT_TOKEN!,
});
In your .env.local for dev, and in Vercel → Project Settings → Environment Variables for production.
curl -A "GPTBot/1.0" -I https://yourdomain.com/ # Look for: x-edgeoptimize-request-id and x-edgeoptimize-bot-detected: 1
Standard Express middleware for Node.js apps not on Vercel or Cloudflare.
npm install @mentionfox/foxedge-middleware
Mount BEFORE your routes. The middleware only intercepts requests that match the LLM allowlist; everything else passes through to next().
import express from 'express';
import { foxEdgeMiddleware } from '@mentionfox/foxedge-middleware/express';
const app = express();
// Mount BEFORE your routes:
app.use(foxEdgeMiddleware({
token: process.env.BOTSIGHT_TOKEN!,
}));
// ... your routes below ...
app.get('/', (req, res) => res.send('<h1>hello</h1>'));
app.listen(3000);
Add to your .env (loaded via dotenv) or your hosting provider's env-var UI (Railway, Render, Fly, etc.).
curl -A "GPTBot/1.0" -I https://yourdomain.com/ # Look for: x-edgeoptimize-request-id and x-edgeoptimize-bot-detected: 1
Pro / Agency / Enterprise · 5-day free trial regardless of tier.
See pricing Get my install tokenAlready a customer? Your token lives at /dashboard/geofixer → FoxEdge tab.