BACKEND, can be read and
set, but not
Available in all subroutines.
The backend to use to service the request.
Try it out
req.backend is used in the following solution recipes, which show real world use cases. Click RUN to provision a Fastly service, execute the code on Fastly, and see how the function behaves.
URL path based routing for microservices
Send request to different origin servers based on the URL path.
Smoke test a new origin
Send a copy of your traffic to a test origin before returning a response from production.
Failover to a secondary backend
If primary backend fails, retry with a different backend without caching the failure or reducing cache efficiency.
Custom condition for triggering WAF
The web application firewall runs only on traffic to your origin, but you can further refine when it should be invoked.
User contributed notes
We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.