inspect
Inspect a request using the Fastly Next-Gen WAF.
Note: Can only be used when processing requests, not during build-time initialization.
Parameters
- request: Request
The request to inspect.
- config: InspectConfig
Configuration for the inspection.
Returns
Throws
- {TypeError} If
requestis not a Request instance. - {TypeError} If
overrideClientIpis not a valid IPv4 or IPv6 address.
12345678910111213141516171819202122/// <reference types="@fastly/js-compute" />
import { inspect } from "fastly:security";
async function app(event) { const res = inspect(event.request, { corp: "my-corp", workspace: "my-workspace" }); switch (res.verdict) { case "allow": return await fetch(event.request); case "block": return new Response("Request Blocked", { status: 400 }); case "unauthorized": return new Response("Unauthorized", { status: 401 }); default: return new Response("Unexpected verdict", { status: 500 }); }}
addEventListener("fetch", (event) => event.respondWith(app(event)));