Open wytxer opened 3 months ago
Hi @wytxer, Thank you for opening this bug report with all the details. I am sorry that you are running into this issue.
Our node SDK was built for Node.js Runtime, as Edge runtime uses web API some of the dependencies we use like the crypto
module will not work.
Even though removing the node:
prefix might solve the problem for you, I fear it will break for others. So that is not an option.
I will find a solution to this problem and get back to you once it is released.
Thank you.
Thank you for your reply. I am building a product based on Cloudflare Worker. Is there a plan for when it will be released? @vijayasingam-paddle
Hi @wytxer, I am afraid that it will take a while for us to change this as we had not planned to run our SDK using web APIs and supporting both runtimes will be tricky.
We do support CloudFlare workers using NodeJS runtime. However, looking at your snippet, you are deploying a NextJS app to CloudFlare workers which as I understand can only run on an edge runtime.
If you don't mind me asking, is there any particular reason not to deploy this in Vercel or Netlify where the infra plays well with NextJS applications compared to CF workers?
Thank you.
@vijayasingam-paddle I'm trying to implement paddle in Cloudflare workers, As you mentioned,
We do support CloudFlare workers using NodeJS runtime.
I'm planning to use Cloudflare workers as the backend, so could you let me know if this works?
Hi @westlinkin, Yes, our SDK works in CloudFlare workers using NodeJS runtime. This issue is relevant only to the Edge runtime
Please feel free to reach out to us if you face any difficulties while integrating with your application.
Thank you.
Oh, I use CloudFlare Worker as the backend, node:crypto
prevents me continuing.
Hi @richhost, We haven't made any progress on this yet. As we had not planned to support this, it is taking longer to prepare for this change.
Meanwhile, can you please try version 1.2.2
? We were using crypto
as a dependency at this point so it might work for you.
There are a few functional differences between 1.2.2
and the latest version. You can read through our Changelog to find the differences
I will get back to you once a proper fix is released.
Thank you.
Hi @wytxer, I am afraid that it will take a while for us to change this as we had not planned to run our SDK using web APIs and supporting both runtimes will be tricky.
We do support CloudFlare workers using NodeJS runtime. However, looking at your snippet, you are deploying a NextJS app to CloudFlare workers which as I understand can only run on an edge runtime.
If you don't mind me asking, is there any particular reason not to deploy this in Vercel or Netlify where the infra plays well with NextJS applications compared to CF workers?
Thank you.
Because the website that is already online is based on Cloudflare Worker, migrating the entire site to a platform like Vercel to use the Paddle API would be very costly.
@vijayasingam-paddle I'm trying to implement paddle in Cloudflare workers, As you mentioned,
We do support CloudFlare workers using NodeJS runtime.
I'm planning to use Cloudflare workers as the backend, so could you let me know if this works?
Bro, you can consider trying the version I forked: https://github.com/wytxer/paddle-node-sdk. I changed crypto to crypto-js, and one of my projects is using it. The API is completely consistent with the official version. You can click to check my modification history.
npm i @wytxer/paddle-node-sdk
Hello, you could try this in your next.config.js:
webpack: (config) => {
config.externals.push({
'node:crypto': 'commonjs crypto',
});
return config;
},
What happened?
Using the Next.js 14 + TypeScript tech stack, with the API set to the edge environment, an error occurs when calling paddle.transactions.create after importing the @paddle/paddle-node-sdk package: Module build failed: UnhandledSchemeError: Reading from "node:crypto".
Steps to reproduce
Reproduction code snippet:
What did you expect to happen?
I hope to use @paddle/paddle-node-sdk in an edge environment.
Logs