Put a worker live // where should the A record point?


#1

Hi,

I wrote a super simple worker from the editor:

addEventListener('fetch', event => {
  const meta = {
    headers: {
      "Content-Type": "text/html",
    },
    status: 200,
  }
  
  const body = `<!DOCTYPE html>
  <html>
    <head>
      <title>My App</title>
    </head>
    <body>
      <h1>My App</h1>
      <p>url: ${event.request.url}</p>
    </body>
  </html>`;
  
  event.respondWith(
    new Response(body, meta)
  )
})

And it is working in the cloudflare frame. But not from the actual website.

I enabled the website on those routes:

What did I miss ?


#2

(I enabled the workers and payed for it. And I did hit the deploy button.)


#3

(And the error I have when I try to curl is “Could not resolve host”)


#4

Oh, I think I know what went wrong. I have no A record

An A, AAAA or CNAME record was not found pointing to the root domain. The my-ndd.tld domain will not resolve.

Where should the A record point if the only thing I want is a worker ?


#5

If the worker is acting purely as an endpoint and not a proxy, the A record can point anywhere. Common choices are to point the A/AAAA at your registrar’s default parking site, or CNAME it to your GitHub Pages domain if you have one.

This requirement is admittedly a little silly, since presumably you’re not going to forward any subrequest to the origin. It is a consequence of the history of our infrastructure’s primary use as a proxy, and we hope to remove the requirement at some point.

Harris


#6

Oh, right!

I added an A record to 12.34.56.78 and now everything is working. Thank you very much.

It could be mentioned somewhere :slight_smile: