Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Mollie on Cloudflare Workers #208

Open
jvanmourik opened this issue May 30, 2021 · 10 comments
Open

Using Mollie on Cloudflare Workers #208

jvanmourik opened this issue May 30, 2021 · 10 comments
Assignees
Labels
enhancement Improvements and changes outside of API endpoints. need more info This needs to be discussed or investigated more.

Comments

@jvanmourik
Copy link

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

@Pimm
Copy link
Collaborator

Pimm commented Jun 1, 2021

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.

@Pimm Pimm self-assigned this Jun 1, 2021
@nielswhydonate
Copy link

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 :)

@Pimm
Copy link
Collaborator

Pimm commented Jan 5, 2022

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.)

@nielswhydonate
Copy link

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.

@ItsWendell
Copy link

Would love to see support for this!

@hansottowirtz
Copy link

As axios would need to be replaced with fetch (axios doesn't work in Cloudflare Workers), see axios/axios#1219 and slackapi/node-slack-sdk#1335 for similar issues.

@renancouto
Copy link

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

@Pimm
Copy link
Collaborator

Pimm commented Jul 3, 2023

Thanks, Renan.

@rkettelerij
Copy link

rkettelerij commented Aug 24, 2023

Any news on this? Cloudflare Worker support would be great.

@Gerbuuun
Copy link

Would love to see platform agnostic support! Maybe something like this could help a lot https://github.com/unjs/unenv

@janpaepke janpaepke added the enhancement Improvements and changes outside of API endpoints. label Sep 11, 2024
@janpaepke
Copy link
Collaborator

@Pimm Given that 4.0.0 will remove the axios dependency, there's at least one less obstacle here.
Do we want to plan this for 4.1.0 or 4.2.0?

@janpaepke janpaepke added the need more info This needs to be discussed or investigated more. label Sep 11, 2024
@Gerbuuun
Copy link

Cloudflare also has announced massively improved Node.js compatibility just two days ago which should make it a lot less work: https://blog.cloudflare.com/more-npm-packages-on-cloudflare-workers-combining-polyfills-and-native-code/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements and changes outside of API endpoints. need more info This needs to be discussed or investigated more.
Projects
None yet
Development

No branches or pull requests

9 participants