Functions - JavaScript Examples
Using functions on the Azion Web Platform allows you to have closer and faster communication with users. By making use of JavaScript, you’re able to effectively perform tasks that have a great impact on people’s lives and business on a daily basis.
This collection gathers ready-to-use JavaScript snippets that show common patterns for functions, from returning a simple response or JSON payload to redirecting traffic, reading cookies, running A/B tests, and applying firewall rules based on GeoIP data. The examples are grouped by where they run: functions that respond to the fetch event in applications, and functions that handle the firewall event for security and request control. To use any of them, copy the code into a function and deploy it on Azion, optionally customizing behavior through args so the same logic can be reused across instances.
Functions - Applications
Redirect all requests to one URL
Functions - Firewall
General functions on firewall example