url dinamicos

I’m experiencing difficulties with setting up dynamic subdomains for my web application, and I’m seeking assistance to resolve this issue.

I’ve created a Cloudflare worker to act as a reverse proxy server. This worker intercepts requests to my domain and redirects them to the corresponding URL on Vercel, based on the subdomain of the incoming request. Here is the code for the worker:

addEventListener('fetch', event => {

async function handleRequest(request) {
  let url = new URL(request.url);

  if (isStaticFileRequest(url.pathname) || url.pathname.endsWith('.json')) {
    url.hostname = 'pre-deploy-url';
    request = new Request(url, request);
  } else if (isValidSubdomain(url.hostname)) {
    url.hostname = 'pre-deploy-url';
    request = new Request(url, request);

  let response = await fetch(request);
  return response;

function isStaticFileRequest(pathname) {
  const staticFileExtensions = ['js', 'css', 'png', 'jpg', 'jpeg', 'svg', 'gif', 'ico', 'json'];
  return staticFileExtensions.some(ext => pathname.endsWith('.' + ext));

function isValidSubdomain(subdomain) {
  return true;

In order for this to work, I’ve purchased a domain on Cloudflare and associated it with the worker URL. This makes my application globally accessible at https://juliopavila.work/.

The problem arises when a user tries to set up their own custom subdomain using a CNAME record pointing to juliopavila.work. Instead of redirecting to the pre-deployed version of the application as expected, an SSL/TLS error occurs.

The error I receive on Brave browser is: “Unsupported protocol: The client and server don’t support a common SSL protocol version or cipher suite.”

My question is: how can I correctly configure SSL/TLS for my domain on Cloudflare so that it can support custom subdomains that are set up with CNAME records pointing to juliopavila.work?

I would greatly appreciate any suggestions or advice you could provide to resolve this issue.

Thank you in advance for your help!