Next.js Discord

Discord Forum

Cloudflare and Next.js

Answered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Hello! Im trying to implement my Next.js project on Cloudflare Pages.

While trying to do so, I encounter an error related to webpack, PayPal SDK and vercel(?) as far as I can understad, but I really can´t understand lol, so hopefully someone in here can help me out.

18:10:52.286    â–²  ./node_modules/@paypal/checkout-server-sdk/lib/orders/ordersPatchRequest.js:9:20
18:10:52.286    â–²  Module not found: Can't resolve 'querystring'
18:10:52.287    â–²  
18:10:52.287    â–²  https://nextjs.org/docs/messages/module-not-found
18:10:52.287    â–²  
18:10:52.287    â–²  Import trace for requested module:
18:10:52.287    â–²  ./node_modules/@paypal/checkout-server-sdk/lib/orders/lib.js
18:10:52.287    â–²  ./node_modules/@paypal/checkout-server-sdk/lib/lib.js
18:10:52.287    â–²  ./node_modules/@paypal/checkout-server-sdk/index.js
18:10:52.287    â–²  ./app/api/checkout/route.tsx
18:10:52.287    â–²  ./node_modules/next/dist/build/webpack/loaders/next-edge-app-route-loader/index.js?absolutePagePath=private-next-app-dir%2Fapi%2Fcheckout%2Froute.tsx&page=%2Fapi%2Fcheckout%2Froute&appDirLoader=too_long_to_paste_in_here
18:10:52.288    â–²  > Build failed because of webpack errors
18:10:52.337    â–²  Error: Command "npm run build" exited with 1
18:10:52.422    
18:10:52.423    ⚡️ The Vercel build (`npx vercel build`) command failed. For more details see the Vercel logs above.
18:10:52.423    ⚡️ If you need help solving the issue, refer to the Vercel or Next.js documentation or their repositories.
Answered by Ray
use their rest api instead if you are deploying to cloudflare
View full answer

6 Replies

@Masai Lion Hello! Im trying to implement my Next.js project on Cloudflare Pages. While trying to do so, I encounter an error related to webpack, PayPal SDK and vercel(?) as far as I can understad, but I really can´t understand lol, so hopefully someone in here can help me out. 18:10:52.286 ▲ ./node_modules/@paypal/checkout-server-sdk/lib/orders/ordersPatchRequest.js:9:20 18:10:52.286 ▲ Module not found: Can't resolve 'querystring' 18:10:52.287 ▲ 18:10:52.287 ▲ https://nextjs.org/docs/messages/module-not-found 18:10:52.287 ▲ 18:10:52.287 ▲ Import trace for requested module: 18:10:52.287 ▲ ./node_modules/@paypal/checkout-server-sdk/lib/orders/lib.js 18:10:52.287 ▲ ./node_modules/@paypal/checkout-server-sdk/lib/lib.js 18:10:52.287 ▲ ./node_modules/@paypal/checkout-server-sdk/index.js 18:10:52.287 ▲ ./app/api/checkout/route.tsx 18:10:52.287 ▲ ./node_modules/next/dist/build/webpack/loaders/next-edge-app-route-loader/index.js?absolutePagePath=private-next-app-dir%2Fapi%2Fcheckout%2Froute.tsx&page=%2Fapi%2Fcheckout%2Froute&appDirLoader=too_long_to_paste_in_here 18:10:52.288 ▲ > Build failed because of webpack errors 18:10:52.337 ▲ Error: Command "npm run build" exited with 1 18:10:52.422 18:10:52.423 ⚡️ The Vercel build (`npx vercel build`) command failed. For more details see the Vercel logs above. 18:10:52.423 ⚡️ If you need help solving the issue, refer to the Vercel or Next.js documentation or their repositories.
Paypal sdk uses node api which doesn’t work with cloudflare worker
use their rest api instead if you are deploying to cloudflare
Answer
@Ray Paypal sdk uses node api which doesn’t work with cloudflare worker
Masai LionOP
Ohhh yeah makes sense lol
@Ray use their rest api instead if you are deploying to cloudflare
Masai LionOP
I will give a look to the Rest API docs then, thanks Ray!
We missed you
I will mark this as a solved and well, it I need help with the Rest API I will open a new forum and hopefully you can help me