Deploy NexJS Site to CloudFlare Pages with Wrangler
Hi
I have a monorepo setup (nx). Because monorepo is not supported by CloudFlare Pages, I would like to deploy the build folder manually using wrangler.
npx wrangler pages deploy ./apps/app-nam --project-name mono-test-01
This folder includes the ./next/ output folder, as well as a package.json file, with a script, "start", being npx next start
This uploads the files, but the link shows a 404.
Any advice, how can I get the .next folder to run? 6 Replies
Try
npx wrangler pages deploy ./apps/app-nam/.next/output --project-name mono-test-01
, or whatever the output folder is namedHmm no /output/ folder. The site also uses SSR features (not static).
Haven't got next-on-pages working fully with nx yet, but I managed to do it on a test app, by removing nx from the next.config.js file
npx @cloudflare/next-on-pages@1
This now builds successfully, having remvoed nx from next.config.js
I now need to upload "direct upload" using wrangler:
npx wrangler pages deploy . --project-name mono-test-01
The files get uploaded (see screenshot).
But since it is Direct Upload (not Git connected), seems that CloudFlare does not know to run it as a next app.
It can't be git connected, because it's a monorepo.
Any ideas?You want to deploy
.vercel/output/static
Interestingly that now shows an error page at least.
I added nodejs_compat compatibility and will now redeploy 🤞 Thanks @HardlyWorkin' that worked for my simple Nextjs app, will now try with a more advanced app in the repo, which has SSR, etc.
Node.JS Compatibility Error
I added nodejs_compat compatibility and will now redeploy 🤞 Thanks @HardlyWorkin' that worked for my simple Nextjs app, will now try with a more advanced app in the repo, which has SSR, etc.