Custom Data Plugin - Need another option than using the toUrl method

Hello,

I’m currently in the process of building a custom data plugin to gather data from a headless CMS. I have been referencing the provided example, but I’ve encountered an issue related to the ResourceType. It seems that the code expects a ‘toUrl’ property, taking the Contentful code example you shared:

const params = qs.stringify(
{ …options, fields, access_token: accessToken, content_type: type.sys.id },
{ allowDots: true, skipNulls: true }
);
// by query
return buildUrl(
https://cdn.contentful.com/spaces/${spaceId}/environments/master/entries?${params},
locale
);

The problem I’m facing is that the headless CMS I’m working with does not allow querying the data endpoint by passing the token as a query string. Instead, for security reasons, it requires the token to be sent through HTTP headers.

I’m reaching out to inquire if there are any alternative options available to overcome this limitation and make the integration work smoothly.

Thank you in advance for your assistance. I greatly appreciate your help!

Best regards

Hello Miguel,

Does the following forum post offer a solution to your issue?

There are a few resource suggestions there that deal with dynamic URLs.

Let me know if this doesn’t steer us in the right direction.

Hello @MiguelMinoldo,

I just wanted to follow up with you. Did the prior solution work or are you still experiencing the issue?

Hello @JuliusGD,
Unfortunately, the above suggestion doesn’t help me to workaround the issue. The Headless CMS I’m trying to create the plugin for doesn’t accept an API key or token to be sent as query string (security reasons) but only as an HTTP Header, and this appears to be the only way of implementing Data Plugins unless I’m missing something?
Thanks in advance for your help!
Miguel

Hello Miguel,

I think, at this point in time, the only workaround I can suggest is to create a custom endpoint in your API that can receive the data without a query param and then forward that along with your access token to the CMS.

Thanks Julius, yes, that’s the approach I’m working on at the moment, and is actually working.

@MiguelMinoldo

I’m glad to hear that!
In the future, for a more timely response directly from Builder please reach out to support@builder.io.

Thanks for your patience.