title | description | meta_tags | namespace | permalink | menu_namespace |
---|---|---|---|---|---|
Exemplos em JavaScript - 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. |
edge computing, javascript, edge functions |
documentation_products_edge_functions_javascript_examples_adding_response_header |
/documentacao/produtos/edge-application/edge-functions/javascript-examples/adding-response-header/ |
runtimeMenu |
Baseando-se no código do país, 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)));
import ContributorList from '~/components/ContributorList.astro'
Contribuidores Contributor