Repository navigation
feat(vercel): one middleware for detection and clearance - #75
Merged
Merged
Conversation
@webdecoy/nextjs/vercel (new) and @webdecoy/node/vercel run detection and the clearance gate together, configured from WEBDECOY_API_KEY and the three clearance variables. With the API key set, bots and the WebDecoy-Test/ trigger are reported; without it @webdecoy/node/vercel is the gate alone, unchanged. Monitor by default, fail open everywhere. - createDetectAndGate() in @webdecoy/node is the framework-free core; createVercelMiddleware() wraps it for Vercel and for Next.js. - Detection and the gate share one client IP and path, so a refusal's match key describes the same request the detection reported. - Local analysis forwards agents the bot registry names. - typesVersions for the vercel and testing subpaths.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A site on Vercel has one middleware file. Detection and the clearance gate used to be separate middlewares with separate credentials, and outside Next.js no middleware reported detections at all. This puts both in one middleware, configured from the environment.
@webdecoy/nextjs/vercel(new subpath). Default export: a ready middleware. Named:createVercelMiddleware(options).@webdecoy/node/vercel: the default export now also reports detections whenWEBDECOY_API_KEYis set. Without it, it is the clearance gate exactly as before. New namedcreateVercelMiddleware(options);clearanceMiddleware()stays as the gate alone.createDetectAndGate()in@webdecoy/node: the framework-free core both use.Env:
WEBDECOY_API_KEY(detection),WEBDECOY_SITE_KEY/WEBDECOY_SCANNER_ID/WEBDECOY_SENSOR_KEY(gate). Either half works without the other; with neither, every request passes. Detection is monitor mode by default; nothing throws.Customer snippets
Next.js (
middleware.ts, orproxy.tson Next 16):Next 16 fails the build on
export { default } from '@webdecoy/nextjs/vercel': its proxy/middleware export check reads the file's AST and does not count a re-exporteddefault. Verified: Next 15.5 builds either form; Next 16.4 builds only the import-then-export form (in bothproxy.tsandmiddleware.ts).Astro / SvelteKit / Nuxt on Vercel (
middleware.ts), unchanged from today:Details
x-webdecoy-decision,x-webdecoy-detection-id,x-webdecoy-would-block), with inbound copies stripped.typesVersionsforvercelandtestingsubpaths: a Next 15 app withmoduleResolution: nodecould not resolve the subpath's types.gate.generated.jsis unchanged.Verification
npm run build,npm run lint(no new warnings),npm test(node 537, nextjs 21, all packages pass),npm run check:edge(all entries, including both newvercel.tsentries).middleware.ts, Edge runtime) and Next 16.4 (proxy.ts) apps. Both build.next start, thencurl -A "WebDecoy-Test/1.0": the page seesx-webdecoy-would-block: trueand a detection id; a browser request seesfalse, with a forged inbound header replaced.