Code Examples

Icon Card background
Ecommerce

This EdgeWorker tests for /commerce/categories in the URI path and responds to a GET parameter named search by running a case-insensitive regex against each title and description field, and a numeric comparison against each ID, returning an array of matching category entities, serialized as JSON. The response is generated at the Edge, so the origin server is not contacted, and the request is resolved at the first Edge server that answers it.

View Case
Icon Card background
Product URL Redirects

Note the URL path changing from /sku/483D5F/reviews to products/straight-fit-denim-jeans/reviews

This example uses EdgeWorkers + EdgeKV to extract a query string product SKU from an incoming URL, match it against a SKU stored in a KV database, and properly redirect the browser to the new product page.

View Case