Specify host header in fetch request

I'm trying to health-check load balanced hosts, for which I need to fetch using IP address + Host header.

In curl it's super simple, like this:
curl -H "Host: direct.openfreemap.org" -I http://144.76.168.195/styles/liberty


However I cannot replicate the same in a Worker JS environment. For example this does not work (network connection lost):

    const resp = await fetch('http://144.76.168.195/styles/liberty', {
      headers: {
        Host: 'direct.openfreemap.org',
      },
    })


How can I make either fetch work with Host headers, or use a lower level library for that?
Was this page helpful?