Question about dynamic metadata

I’m following the tutorial here to set up dynamic metadata Dynamic page metadata | WeWeb Documentation.

I do not wish to use dynamic images. If I exclude the variable from the API response, will dynamic metadata still work? Will it populate with the image metadata already in WeWeb?

1 Like

Follow on question. I tried to deploy the worker and it failed with a “The process ‘/usr/local/bin/npx’ failed with exit code 1” message.

I have somewhat of a unique setup compared to the example code, where I need to pass in 2 variables from the page path. A job type slug and a location slug.

My production url looks like this.

https://www.nursejobs.health/pay/{job_type_slug}/{geo_area_slug}

Worker Configuration

export const config = {
  domainSource: "https://www.nursejobs.health", // Your WeWeb app link
  metaDataEndpoint: "https://xnfj-dys4-m8rx.n7d.xano.io/api:dVTDQ57n/static_pay_metadata/{job_type_slug}/{geo_area_slug}", // Link of the endpoint that returns the metadata. /{id} will be added to this path. With id being the last parameter of the dynamic page
  patterns: {
    dynamicPage: "/pay/[^/]+/[^/]+"
  }
};

I’m not sure if this is the correct way to set this up, or if the code can even handle it. Any guidance would be appreciated.

bump

@Joyce is there anyone I can connect with at WeWeb to get assistance?

Hi @nick,

To make sure the default image is not replaced you need to remove those lines in the index.ts file.

Concerning your request, you need to update this function:

On line 36, we get the last part of the URL. So Id is going to be equal to {geo_area_slug}. You can update those line, like this:

// Split the trimmed URL by '/' and get the last part: The id
const parts = trimmedUrl.split('/');
const geo_area_slug = parts[parts.length - 1];
const job_type_slug = parts[parts.length - 2];

Then you can hard code the request URL like this:

// Replace the placeholder in metaDataEndpoint with the actual id
//const placeholderPattern = /{([^}]+)}/;
const metaDataEndpointWithId = "https://xnfj-dys4-m8rx.n7d.xano.io/api:dVTDQ57n/static_pay_metadata/" + job_type_slug + "/" + geo_area_slug

Tell us if that works for you!

1 Like

I will try this out and get back to you

1 Like

I made the changes and attempted to deploy from Github. I am still receiving the same error.

When I check Cloudflare, it seems like the deployment is active. And I can hit the worker if I click on the “View Version” button. Although it just reloads over and over. Not sure if that is expected.

I proceeded with the setup, but no dynamic metadata is showing for my salary pages. I am using Cloudflare to redirect from a naked domain to WWW, but not sure if that impacts the worker. I also have some other CNAME’s set up per WeWeb’s custom domain instructions.

I took a look at the API endpoint, and it shows no hits. I was able to successfully hit it through my browser though.

After some additional research, I found that the worker is receiving requests successfully from my naked domain name.

https://nursejobs.health/pay/{job_type_slug}/{geo_area_slug}

The worker does throw an exception.

But when I add WWW, the worker no longer receives requests.

I’m not sure how to set up a WWW trigger for the worker without breaking the configuration required by WeWeb for the custom domain, as Cloudflare indicates WWW is already in use.

@Joyce @flo

Any thoughts?

Hey @Joyce and @flo,

Just following up again. I would appreciate any next steps so I can try to launch this for my site.

Thanks - Nick

Hi @nick,

Could you please log in to your Cloudflare account and show us the details on this page?

Also the code has been updated. It may be interesting to fork again this repo. Or check the differences.

@flo I ended up turning the worker off. Let me reconfigure it and get back to you.

@flo , from your image in CLoudflare worker domains, it seems like we need to add the subdomain (www), not the domain. Could this (having set the root domain, and not the www subdomain) be a cause for not seeing the dynamic metadata ?

I am coming across similar issue. I couldn’t do www redirect and set dynamic meta. Did you solve your issue?