1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20

doc

Adicionando um response header

Baseando-se no código do pais, acessado através de event.request.metadata["geoip_country_code"], um response header é adicionado.

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)));

Leia também


Não encontrou o que procurava? Abra um ticket.