mollie-api-node
mollie-api-node copied to clipboard
Using Mollie on Cloudflare Workers
Hello, Is it possible to use this package in combination with Cloudflare Workers? Currently it does not allow for use outside the node process, am I correct?
Error: Unexpected process release name undefined. This may indicate that the Mollie API client is integrated into a website or app. This is not recommended, please see https://github.com/mollie/mollie-api-node/#a-note-on-use-outside-of-nodejs. If this is a mistake, please let us know: https://github.com/mollie/mollie-api-node/issues
Thanks
Thanks for the issue, Jacco!
While it does not allow for use outside of Node.js, this is an artificial limitation.
In the past, we've seen developers attempting to include this library in client-side websites/apps. Doing so would cause requests to be made to the Mollie servers directly from the user's machine, leaking the API key to the public. This is a severe security risk. The check you've discovered was introduced to prevent developers from shooting themselves in the foot. You are unfortunately collateral damage in this case.
To support Cloudflare Workers, we should:
- tweak this check (or ‒ if everything else fails ‒ add a flag which disables the check entirely), and
- ensure the library does not require any Node.js-specific APIs not supported by Cloudflare Workers.
Hi @Pimm @jvanmourik,
We are in the same situation. We are trying to use Mollie from a Cloudflare worker, build on Node.
Is this Mollie Node package fully supported by now? Or does it still require some tweaks for a Cloudflare worker?
If we decide to tweak it, what are the risks of breaking when there is an update from Mollie?
Thanks for your help :)
Hi Niels,
The library currently contains a check introduced to prevent developers from shooting themselves in the foot.
If you remove this check, the library should maybe perhaps work just fine on Cloudflare Workers. However, I haven't tested this yet. And before we announce official support for Cloudflare Workers, I want to test it thoroughly.
This is currently high on the backlog. I plan to look into this after the rollout of 3.6.0. I'll keep you up-to-date. If that just sounds too vague and you're willing to get your hands dirty, you are more than welcome to experiment and get involved. The door to my office is always open. Please feel free to step in at any time. (I'm working from home, so ehm… that stepping in part was meant figuratively.)
Thanks for your response Pimm! Great to hear it's high on the backlog. If we make some progress, I will definitely post it here.
Would love to see support for this!
As axios would need to be replaced with fetch (axios doesn't work in Cloudflare Workers), see https://github.com/axios/axios/issues/1219 and https://github.com/slackapi/node-slack-sdk/issues/1335 for similar issues.
I didn't want to create a new issue, but this problem is also happening on Deno. This runtime doesn't expose a process
object like Node, so targeting it would have to be done in a different way. Maybe this lib could help https://github.com/flexdinesh/browser-or-node/tree/master
Thanks, Renan.
Any news on this? Cloudflare Worker support would be great.
Would love to see platform agnostic support! Maybe something like this could help a lot https://github.com/unjs/unenv