Redirect all requests to one URL
Send every incoming request to one destination URL with a 301 redirect returned by a function, before it reaches your origin.
Redirect every incoming request to a single destination URL directly from Azion’s global network. This is helpful during maintenance windows or downtime, when you want to point all visitors to a status page or an alternate site without changing your origin.
How it works
The function registers a handler for the fetch event with addEventListener. Inside handleRequest, it calls Response.redirect(destinationURL, statusCode) to build a redirect response that points the browser to the configured URL, using the 301 status code to signal a permanent move. Because destinationURL and statusCode are constants, every request receives the same redirect regardless of the original path. event.respondWith() then returns that response, so visitors are redirected without the request ever reaching your origin.