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?
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.
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.
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
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.
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.
@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 ?