Workers get hostname

Hi There,

I want to find out in the if I get traffic from bot traffic for that I want to check the host name,

Is there any way to check the host name inside the workers? or inside the html client (I don’t want to use server side)

I know there is option in the to filter by host firewall buy I want to have some logic inside the worker/client without using server side code…


This is an example from here:

addEventListener('fetch', event => {

async function fetchAndApply(request) {  
  if (request.headers.get('user-agent').includes('annoying_robot')) {
    return new Response('Sorry, this page is not available.',
        { status: 403, statusText: 'Forbidden' })

  return fetch(request)

Thanks for the example

However I looking for the ISP of the visitor

So I will be able the check if the ISP if its real service provider or hosting company

Then you could limit by Autonomous System Number:

Great! any idea how can I get the ASN Name ? (and not the number)

One way:

Great found it!