How to deploy next app using cloudflare workers?

I know that cloudflare offers pages for easy deployment of next. I cannot use pages because my repo is not hosted on github/gitlab. I looked at next-on-pages project and I am building my project using next-on-pages as the build command in my script which creates a .vercel directory and I have setup the main file of the worker correctly as well. This is my wrangler.toml file:
name = "dashboard"
type = "javascript" # or "module" if you are using the modules syntax
main = ".vercel/output/static/_worker.js/index.js"

compatibility_date = "2024-08-24"
compatibility_flags = [ "nodejs_compat" ]

[site]
bucket = ".vercel/output/static"

[env]
workers_dev = true # or false if you're deploying to a custom domain

[build]
command = "npm run cfbuild"
name = "dashboard"
type = "javascript" # or "module" if you are using the modules syntax
main = ".vercel/output/static/_worker.js/index.js"

compatibility_date = "2024-08-24"
compatibility_flags = [ "nodejs_compat" ]

[site]
bucket = ".vercel/output/static"

[env]
workers_dev = true # or false if you're deploying to a custom domain

[build]
command = "npm run cfbuild"
where cfbuild is my custom script. I deploy this project to workers using wrangler deploy and the deployment happens correctly but when I visit the worker link, I am getting Internal Server Error. How do i fix it?
6 Replies
Hello, I’m Allie!
You can use Pages via wrangler pages deploy, even if you don't use GitHub/Lab I don't think we support Workers deploys for next-on-pages
YoYo
YoYoOP3mo ago
If i do wrangler pages deploy, the build is going to be created locally first right?
Hello, I’m Allie!
Doing wrangler pages deploy doesn't build anything. You still need to build with next-on-pages first
YoYo
YoYoOP3mo ago
Yes, that's exactly what I was asking. Also, is there a need to have wrangler toml as well or i need to configure it by going to the cf dashboard?
Hello, I’m Allie!
You can configure bindings etc via the dashboard if you want
YoYo
YoYoOP3mo ago
I did wrangler pages deploy and the deployment has been created and I can see it in the cf dashboard as well but when I am visiting the link now, it is showing This site can’t be reached chrome page. This is my wrangler toml file for pages:
name = "dashboard"
type = "javascript" # or "module" if you are using the modules syntax


compatibility_date = "2024-08-24"
compatibility_flags = [ "nodejs_compat" ]

# If your project uses any environment variables, you can define them here.
# [env.production]
# VAR_NAME = "value"


pages_build_output_dir = ".vercel/output/static"
name = "dashboard"
type = "javascript" # or "module" if you are using the modules syntax


compatibility_date = "2024-08-24"
compatibility_flags = [ "nodejs_compat" ]

# If your project uses any environment variables, you can define them here.
# [env.production]
# VAR_NAME = "value"


pages_build_output_dir = ".vercel/output/static"
What am i doing wrong? Ah, it worked. I thought the DNS changes are instant, it took a while but I can see it now. Thanks for the help
Want results from more Discord servers?
Add your server