# JavaScript Examples - Adding a response header

Add a response header based on the visitor's country, resolved from GeoIP data on Azion's global network. Use this pattern in a firewall function to tag or flag traffic from specific regions, for example to drive country-specific logic downstream without blocking the request.

```js
async function firewallHandler(event){
    // Access the country code through geoip
    let countryCode = event.request.metadata["geoip_country_code"]

    // Do some logic here
    // In this example, if the request comes from Brazil, we add a header to the response
    if (countryCode === "BR"){
        event.addResponseHeader("test", "true");
    }

    // Then, if it comes from any other country,
    // the processing continues
    event.continue();
}

addEventListener("firewall", (event)=>event.waitUntil(firewallHandler(event)));
```

## How it works

The function listens for the `firewall` event with `addEventListener`, wrapping the asynchronous handler in `event.waitUntil()` so processing completes before the event ends. It reads the country code from `event.request.metadata["geoip_country_code"]`, and when the visitor is from Brazil it calls `event.addResponseHeader("test", "true")` to attach a custom header to the response. Finally, `event.continue()` lets the request proceed normally so it reaches its destination instead of being blocked.

## Related resources

- [JavaScript examples](/en/documentation/devtools/javascript-examples/)
- [Runtime APIs](/en/documentation/products/applications/functions/runtime-apis/javascript/fetch-event/)