# Dynamic Metadata through Cloudflare don't appear

**URL:** <https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099>\
**Category:** Ask us anything\
**Tags:** cloudflare\
**Created:** [September 28, 2024, 10:42am UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099 "2024-09-28T10:42:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pinshasa](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/pinshasa/32/7088_2.png) [@pinshasa](https://community.weweb.io/u/pinshasa)\
**Post date:** [September 28, 2024, 10:42am UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/1 "2024-09-28T10:42:08Z")

</div>

I made the Cloudflare setup as per the tutorial, the worker seems to work (I see the requests made to it), but the dynamic metadata don’t appear on my page.

I’m using Baserow, the object contains the 4 elements required (among the other elements of the object), but the metadata are still the default ones of the website, or the default ones of the template page, instead of the ones through the Cloudflare Worker.

How to troubleshoot this further?  
@Slavo @flo  
.

---

<div class="post-metadata">

**Author:** ![DanielL](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/daniell/32/13398_2.png) [@DanielL](https://community.weweb.io/u/DanielL)\
**Post date:** [September 30, 2024, 4:25pm UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/2 "2024-09-30T16:25:51Z")

</div>

Helo @pinshasa 👋

Can you please make a screen recording describing the issue?

---

<div class="post-metadata">

**Author:** ![pinshasa](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/pinshasa/32/7088_2.png) [@pinshasa](https://community.weweb.io/u/pinshasa)\
**Post date:** [October 1, 2024, 9:23am UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/3 "2024-10-01T09:23:20Z")

</div>

Hi @DanielL

Thanks for your message, here is the video [Weweb Dynamic Metadata Issues 🔍](https://www.tella.tv/video/weweb-dynamic-metadata-issues-gnx1)

---

<div class="post-metadata">

**Author:** ![caffeinatedwes](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/caffeinatedwes/32/625_2.png) [@caffeinatedwes](https://community.weweb.io/u/caffeinatedwes)\
**Post date:** [October 1, 2024, 5:05pm UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/4 "2024-10-01T17:05:10Z")

</div>

Hi @DanielL, would you be able to help our team as well?

JJ from our team posted [this thread](https://community.weweb.io/t/help-needed-with-weweb-metadata-implementation-using-cloudflare-worker/12780) and Greg from our team posted [this thread](https://community.weweb.io/t/what-happens-behind-the-scenes-when-we-implement-a-dynamic-header-using-cloudflare/10056), but we still haven’t been able to resolve things.

---

<div class="post-metadata">

**Author:** ![pinshasa](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/pinshasa/32/7088_2.png) [@pinshasa](https://community.weweb.io/u/pinshasa)\
**Post date:** [October 2, 2024, 8:56am UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/5 "2024-10-02T08:56:08Z")

</div>

Hi @DanielL & @flo ,

As discussed yesterday with @flo in the Office Hours, I’ve tried to access the Worker logs to see where is the issue (Weweb, or Baserow API call, or…), following [their tutorial](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs).  
I added the configuration Cloudflare indicates in the wrangler.toml file of my Github repo, but nothing changed (still can’t see the logs).  
I deployed the worker again, but nothing changed (still can’t see the logs).

 ![Capture d’écran 2024-10-02 à 10.52.08](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/c/c89668bcf7e67ece89e015fdd67fee3ea7ff38cb.png)  
 ![Capture d’écran 2024-10-02 à 10.51.33](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/6/60c03e27ffc3da6b89f22e164f2583166cba9052.png)

Maybe you have an idea of why I still don’t see the logs (where was I wrong here) ?

---

<div class="post-metadata">

**Author:** ![DanielL](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/daniell/32/13398_2.png) [@DanielL](https://community.weweb.io/u/DanielL)\
**Post date:** [October 2, 2024, 9:35am UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/6 "2024-10-02T09:35:50Z")

</div>

Hi @pinshasa and @caffeinatedwes

Can you please create a ticket here so we can have a better look: [https://support.weweb.io/](https://support.weweb.io/)?

We will also update our documentation on this.

---

<div class="post-metadata">

**Author:** ![pinshasa](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/pinshasa/32/7088_2.png) [@pinshasa](https://community.weweb.io/u/pinshasa)\
**Post date:** [October 2, 2024, 10:06am UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/8 "2024-10-02T10:06:09Z")

</div>

ok, ticket sent !

---

<div class="post-metadata">

**Author:** ![pinshasa](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/pinshasa/32/7088_2.png) [@pinshasa](https://community.weweb.io/u/pinshasa)\
**Post date:** [October 30, 2024, 7:20pm UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/9 "2024-10-30T19:20:35Z")

</div>

Hi @DanielL,

It’s been almost a month now, and still not a single follow up on this quite critical issue, whether in my ticket or here.  
Any chance for it to be solved, or should I capitulate?

---

<div class="post-metadata">

**Author:** ![ryanev](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@ryanev](https://community.weweb.io/u/ryanev)\
**Post date:** [October 30, 2024, 8:46pm UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/10 "2024-10-30T20:46:42Z")

</div>

@pinshasa yeah there have been quite a few Cloudflare-related issues posted in the forum over the past couple months.

The most recent WeWeb update was about two weeks ago, stating that it would take a bit of time for them to come up with a solution but it’s being actively worked on.

> [@Dynamic metadata](https://community.weweb.io/t/dynamic-metadata/13923/11):
>
> Yes, I had totally forgotten about the tool. Thank you.

> [@Help Needed with WeWeb Metadata Implementation Using Cloudflare Worker](https://community.weweb.io/t/help-needed-with-weweb-metadata-implementation-using-cloudflare-worker/12780):
>
> Hi Team, We’re working on building a Proof of Concept (POC) before fully implementing WeWeb’s recommendations on metadata for dynamic pages using a Cloudflare Worker. We’re facing an issue where, although the metadata is correctly returned in the worker logs, the HTML isn’t being updated, and the page is not rendering as expected. Here are a few questions we have: Domain Configuration for WeWeb Project: Given that the worker should act as the entry point for at least some pages, what should …

> [@Dynamic Meta Data via Cloudflare](https://community.weweb.io/t/dynamic-meta-data-via-cloudflare/13841):
>
> Hi guys, I’ve seen this asked multiple times in the community, but have yet to come across an answer to this issue many users seem to be facing. I’m having trouble re-creating the expected behavior of the dynamic metadata worker via cloudflare. My suspicion is that because my site is treated as a SPA, the requests are only triggered after navigating from the dynamic page as opposed to loading of the dynamic page. Any ideas how we can resolve this issue?

> [@Can't add custom domain to Cloudflare worker](https://community.weweb.io/t/cant-add-custom-domain-to-cloudflare-worker/13725/2):
>
> I am really struggling with this. Does anyone could help? I already have record in DNS setting which I am using for www redirect but this is something I can’t remove.

> [@Hosting issue with cloudflare and dynamic page indexing](https://community.weweb.io/t/hosting-issue-with-cloudflare-and-dynamic-page-indexing/9999):
>
> Hi there, I’ve been following the tutorial from this link: The issue I’m encountering is that my WeWeb plan already has a custom domain hosted on Cloudflare. When I set up the worker (as explained at the end of the Deploy & Redirect video), I needed to add a custom domain. However, this conflicts with the domain already hosted by WeWeb’s DNS. I tried deleting the WeWeb DNS and adding the worker’s DNS instead, but I got a 502 error and my website went offline. What steps should I take to re…

---

<div class="post-metadata">

**Author:** ![DanielL](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/daniell/32/13398_2.png) [@DanielL](https://community.weweb.io/u/DanielL)\
**Post date:** [October 31, 2024, 1:39am UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/11 "2024-10-31T01:39:41Z")

</div>

Hi @pinshasa @ryanev

@Joyce will shed some light on this

---

<div class="post-metadata">

**Author:** ![ryanev](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@ryanev](https://community.weweb.io/u/ryanev)\
**Post date:** [October 31, 2024, 5:17pm UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/12 "2024-10-31T17:17:46Z")

</div>

Thanks @DanielL!

---

<div class="post-metadata">

**Author:** ![Jay12](https://avatars.discourse-cdn.com/v4/letter/j/6f9a4e/32.png) [@Jay12](https://community.weweb.io/u/Jay12)\
**Post date:** [December 5, 2024, 12:06pm UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/13 "2024-12-05T12:06:20Z")

</div>

Hi @DanielL any update on this matter?

did anyone manage to make the dynamic metadata work recently?

I tried but failed a while ago and I am wondering if I could take a stab again.

---

<div class="post-metadata">

**Author:** ![chubao.uk](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@chubao.uk](https://community.weweb.io/u/chubao.uk)\
**Post date:** [December 30, 2024, 10:18am UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/14 "2024-12-30T10:18:38Z")

</div>

hey @Jay12  
I have a similar problem here, but i found that when i access the page without “www.”  
the dynamic metatag will work

the worker only works on a custom domain without www.

can you try in your side and see if your worker also works without “www.” ?

I tried to redirect all www. to no www. but i will get a infinite redirect… i think it is some settings between weweb / cloudflare, @DanielL any idea?

---

<div class="post-metadata">

**Author:** ![pinshasa](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/pinshasa/32/7088_2.png) [@pinshasa](https://community.weweb.io/u/pinshasa)\
**Post date:** [December 30, 2024, 11:01am UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/15 "2024-12-30T11:01:07Z")

</div>

Hey @Jay12 ,  
No news to my knowledge, unfortunately.

Couldn’t afford this absence of a solution after all the work put in it, so we just decided to migrate to another frontend for that app.

Apparently @chubao.uk found a beginning of workaround, so let’s hope the last mile of fix will be achieved soon!

---

<div class="post-metadata">

**Author:** ![chubao.uk](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@chubao.uk](https://community.weweb.io/u/chubao.uk)\
**Post date:** [December 31, 2024, 6:03pm UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/16 "2024-12-31T18:03:50Z")

</div>

Updates here:  
I’ve been working around with Cloudflare settings and unable to access website without www. now…  
the cloudflare worker can’t work in www. because we need to assign www. to weweb cname.

there are some solution by ChatGPT something like move www. behind cloudflare, not sure if it is possible for weweb.

---

<div class="post-metadata">

**Author:** ![vfede](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/vfede/32/14020_2.png) [@vfede](https://community.weweb.io/u/vfede)\
**Post date:** [May 22, 2025, 9:42am UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/17 "2025-05-22T09:42:07Z")

</div>

i figured it out, it now works for me.

i’m using the cloudflare reverse proxy. i just followed [the guide](https://docs.weweb.io/pages/dynamic-page-metadata.html#metadata-for-dynamic-pages), even if some cloudflare UI was updated, it stays more or less the same. biggest struggles were:

- figure out how to make it work with supabase
- fix the pattern matching in the config to skip css and js files, or page load would break
- use the cloudflare Routes to avoid touching the DNS

all the meta tags in the head are updated with dynamic content that is in my db, you can check the head source code of eg this page [https://www.nomadretreats.co/experience/workation-in-tursi-italy-in-may-by-tursi-digital-nomads/](https://www.nomadretreats.co/experience/workation-in-tursi-italy-in-may-by-tursi-digital-nomads/)

only one caveat. even if my reverse proxy updates the title tag, weweb dynamically overwrites it after page loads. i’ll try to open a bug or get more info on how to prevent this.

## **How to get it to work**

Replace these lines of the original code

> <https://github.com/WeWeb-Public/dynamic-metadata-with-cloudflare-worker/blob/0453691edc4da8c50e18df810979c5ce216db1e4/src/index.ts#L45-L48>

with something like this:

```js
      // Fetch metadata from the API endpoint
      try {
        const metaDataResponse = await fetch(metaDataEndpointWithId, {
          method: 'POST',
          headers: {
            'Authorization': 'Bearer ' + env.SUPABASE_KEY, // Set this in the Cloudflare Worker settings
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({ name: 'Functions' })
        });

        // Check if the response is valid JSON
        if (!metaDataResponse.ok) {
          console.error(`Error fetching metadata: ${metaDataResponse.status} ${metaDataResponse.statusText}`);
          const errorText = await metaDataResponse.text();
          console.error(`Response body: ${errorText}`);
          throw new Error(`Failed to fetch metadata: ${metaDataResponse.status}`);
        }

        return (await metaDataResponse.json());
      } catch (error) {
        console.error('Error in requestMetadata:', error);
        throw error;
      }
    }
    // END of async function requestMetadata(url, metaDataEndpoint)

```

## **Supabase Edge function**

```js
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import { createClient } from 'npm:@supabase/supabase-js@2';
Deno.serve(async (req)=>{
  const corsHeaders = {
    'Access-Control-Allow-Origin': '*',
    'Access-Control-Allow-Methods': 'GET, OPTIONS',
    'Access-Control-Allow-Headers': 'Authorization, Content-Type'
  };
  if (req.method === 'OPTIONS') {
    return new Response('ok', {
      headers: corsHeaders
    });
  }
  try {
    const url = new URL(req.url);
    // Remove any trailing slash from the URL
    const trimmedPath = url.pathname.endsWith('/') ? url.pathname.slice(0, -1) : url.pathname;
    // Extract the slug from the URL
    const slug = trimmedPath.split('/').pop();
    const supabase = createClient(Deno.env.get('SUPABASE_URL') ?? '', Deno.env.get('SUPABASE_ANON_KEY') ?? '', {
      global: {
        headers: {
          Authorization: req.headers.get('Authorization')
        }
      }
    });
    const { data, error } = await supabase.from('your-meta-table').select('meta_title, meta_description, media_ids, tags').eq('slug', slug); // Query by slug
    if (error) {
      throw new Error(`Error fetching experience: ${error.message}`);
    }

// I have images in another table, used for the opengraph preview (not working yet)
    // Fetch media URLs based on media_id
    const mediaIds = data.flatMap((item)=>item.media_ids) || [];
    const { data: mediaData, error: mediaError } = await supabase.from('media').select('id, public_url').eq('id', mediaIds[0]);
    if (mediaError) {
      throw new Error(`Error fetching media: ${mediaError.message}`);
    }
    // Create a map of media IDs to URLs for easy lookup
    const mediaMap = Object.fromEntries(mediaData.map((item)=>[
        item.id,
        item.public_url
      ]));
    // Format the response to match the desired JSON structure
    const formattedData = data.map((item)=>({
        title: item.meta_title,
        description: item.meta_description,
        image: mediaMap[item.media_ids[0]],
        keywords: item.tags ? item.tags.join(", ") : ""
      }));
    // It's an array with one element, take first element
    return new Response(JSON.stringify(formattedData[0]), {
      headers: {
        'Content-Type': 'application/json',
        ...corsHeaders
      },
      status: 200
    });
  } catch (err) {
    return new Response(JSON.stringify({
      message: err.message
    }), {
      headers: {
        'Content-Type': 'application/json',
        ...corsHeaders
      },
      status: 500
    });
  }
});

```

## **Config file**

i had to touch the config file compared to the one in the guide. the pattern with the starting ^ is matching only the right urls. this was critical to make it work for me or the worker would run on css and js files, breaking the whole page loading.

```js
export const config = {
    domainSource: "https://your-preview-weweb-url-123456.weweb-preview.io", // Your WeWeb app preview link
    patterns: [
        {
            // the initial "^" is important to match only the page url, not its styles and scripts that share a similar url
            pattern: "^/provider/[^/]+",
            metaDataEndpoint: "https://your-supabase-url.supabase.co/functions/v1/getMetaProvider/{slug}"
        },
        {
            pattern: "^/experience/[^/]+",
            metaDataEndpoint: "https://your-supabase-url.supabase.co/functions/v1/getMetaExperience/{slug}"
        }
        // Add more patterns and their metadata endpoints as needed
    ]
};

```

* * *

## **DNS**

you don’t need to add a dns like in the guide, a routes option is now available in the workers config. (there’s no reason why one has www and one \*, i was just lazy)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/2/27d7207f1a3b8e51d0a600fc6a73aa1c0a85baee.png)

my dns for the www (the only one i have) stays the same  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/3/34006088baf5fbdf2409aeeceb812f24db40343b.png)

---

<div class="post-metadata">

**Author:** ![vfede](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/vfede/32/14020_2.png) [@vfede](https://community.weweb.io/u/vfede)\
**Post date:** [May 22, 2025, 10:35am UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/18 "2025-05-22T10:35:47Z")

</div>

@DanielL feel free to use my solution to update the docs. the new pattern matching and the Routes option were critical.

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [May 23, 2025, 5:27pm UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/19 "2025-05-23T17:27:46Z")

</div>

You are an absolute star! Thanks so much for taking the time to share this @vfede 😀

---

<div class="post-metadata">

**Author:** ![attlas](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/attlas/32/13956_2.png) [@attlas](https://community.weweb.io/u/attlas)\
**Post date:** [July 6, 2025, 1:24pm UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/20 "2025-07-06T13:24:21Z")

</div>

Hi @vfede , thanks for the clarification. Some days I’m trying to make it works.

Did you add your custom domain in Weweb and keep only the www DNS given ? (because only seeing “cloudfront”). Or your screenshot is a personal random target called cloudfront ?

---

<div class="post-metadata">

**Author:** ![attlas](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/attlas/32/13956_2.png) [@attlas](https://community.weweb.io/u/attlas)\
**Post date:** [July 6, 2025, 2:08pm UTC](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099/21 "2025-07-06T14:08:34Z")

</div>

For those feeling as lost as I was:

I attempted to follow the WeWeb documentation on dynamic metadata. Unfortunately, it doesn’t mention that the information is outdated. There’s an update available, but it’s outdated as well!

Next, I tried the AI support recommendation by “Wiera,” which suggested: **“Remove your custom domain from WeWeb domain settings.”** That approach didn’t work either.

Finally, I followed @vfede’s recommendation, and it worked. The missing part was to add the custom domain into WeWeb too.

* * *

_ **Random information:** Yesterday, my root domain (without www) was working with dynamic data active too. It just stops I don’t know why. I did so much retries, than I’m not feeling able to reproduce the same result, not even sure that is possible, I’m not a specialist_.

[Next page](https://community.weweb.io/t/dynamic-metadata-through-cloudflare-dont-appear/13099.md?page=2)
