Skip to main content
Not on Vercel, Cloudflare or WordPress? You can connect the Agent Edge Network to any backend with a short snippet that calls four Bluemoon endpoints. This guide gives you a copy-paste snippet for Node.js, PHP and Ruby, plus how to route crawler traffic into it from nginx or Apache.
These snippets do the same job as the Next.js middleware, Cloudflare Worker and WordPress plugin. If your language isn’t listed, port one of them, following the steps below.

What your handler does

On each request your handler either serves the optimized version of the page or passes through. Always fail open — if anything errors, serve your normal page.
  1. Match the User-Agent against the crawlers returned by the botset endpoint. Not a known crawler → pass through.
  2. Cloaking firewall. If the crawler is a search index (isSearchIndex: Googlebot, Bingbot, Applebot) → always pass through. See Cloaking firewall.
  3. Verify the crawler with the cidrs the botset endpoint returns for it → IP_VERIFIED if it verifies, UA_ONLY if not.
  4. Check eligibility — verified, the crawler’s purpose is enabled, and your serve mode is Live (default).
  5. Serve the optimized version from the artifact endpoint; if there is none, pass through.
  6. Report the hit to the telemetry endpoint without waiting for the reply.

The endpoints

All calls send Authorization: Bearer <your edge token>. Get the token in Agent Analytics: choose Any other stack and click Connect edge, or open Setup if the site is already connected. Base URL: https://app.trybluemoon.com.

Snippets

Each snippet ships in shadow mode (log-only) — flip SERVE_MODE to "default" when you’re ready to serve. Set your edge token as the AEN_EDGE_TOKEN environment variable.
aen.js
server.js

nginx and Apache

nginx and Apache can’t verify crawlers or fetch the optimized version on their own — but they don’t need to. They already sit in front of an app. Two options:
Run the Node snippet as a tiny sidecar on 127.0.0.1:8788 and send only AI-crawler user-agents to it. Everything else hits your origin unchanged.
The sidecar serves the optimized version to verified crawlers and, for anything it decides to pass through, proxies back to your origin. The user-agent list is only a pre-filter: the sidecar still does the verification and the cloaking firewall.
With mod_rewrite, route AI user-agents to a front controller that includes aen.php.
.htaccess
In aen-entry.php, run the interceptor, then fall back to rendering your normal page:
aen-entry.php

Test it

1

Trigger a real AI crawler

Open ChatGPT (or Perplexity) with browsing and ask it to look up your site.
2

Watch the hit land

The visit appears in Agent Analytics under Recent activity, marked Verified.
3

Go live

Flip SERVE_MODE to "default" and redeploy. See Serve modes.
Everything else — verification levels and serve modes — behaves exactly as it does for the official drop-ins.