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"

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?
Was this page helpful?