Workers.api.error.script_too_large [API code: 10027]

I’m building an SSR environment for Nuxt3 using Cloudflare Workers.

As development progresses and the build size of Nuxt3 increases, the following error occurs during deployment.

workers.api.error.script_too_large [API code: 10027]

Nuxt3 has all the source code of the front end, and it is difficult to compress the build size. The current build size of Nuxt3 is about 19MB.

Even if you delete the image and unnecessary modules, you can expect the size to be reduced by only about 1MB.

Is there any workaround?
I want to continue hosting my SSR environment using Cloudflare Workers.

Is it possible to relax the restrictions on the computing resources that can upload Docker images and the deployment size of Cloudflare Workers?

Please let me know if there is any other suitable solution.

============

Environment

  • Nuxt3
  • deploy by Wrangler(cmd:wrangler publish)
  • Cloudflare workers
  • Cloudflare ImageSizing

wrangler.toml

name = “xxxx”
type = “javascript”
account_id = “xxxxx”
workers_dev = true
route = “”
zone_id = “xxxx”
compatibility_date = “2022-04-07”

[site]
bucket = “.output/public”
entry-point = “.output”

[build]
command = “NITRO_PRESET=Cloudflare npm run build”
upload.format = “service-worker”

The solution is to store your website assets somewhere else rather than bundling them with the code. Cloudflare Pages makes this easy and you don’t pay for the storage.

1 Like

Thank you for answering.

Will CloudFlarePages provide SSR?

Instead of building and configuring static assets, I want to have Nuxt3 SSR with NodeJS.

Yes, you can do SSR with Cloudflare Pages. No, you can’t use NodeJS. I’d recommend you join the https://workers.community/ Discord guild - they know more about which frameworks are supported.

1 Like

I’ve checked the previous question [1], but Cloudflare doesn’t support SSR (server side rendering). It seems that only SSG (nuxt generate) is supported.

Yes, you can do SSR with Cloudflare Pages.

I want to achieve SSR like I did with Wokers for SEO optimization.
It seems that SSR cannot be realized with CloudFlarePages.
If you have any other solution ideas, please share them.

[1] : Will Cloudflare Pages support SSR (Next.js & Nuxt.js)?

For products under development, it is necessary to SSR the information acquired by API communication.
Is there any product other than CloudFlareWorkers that can realize SSR?

If you can do it with Workers, you can do it with Pages

Simply add your SSR into a Function like you did with your Worker. Functions are just Workers after all but bundled into the Pages project.

1 Like

The problem with SSR is that Workers and therefore Pages doesn’t allow you to use exec(), and most templating solutions use that. Mustache works on Pages though, and you can also use HTMLRewriter.

I’m not sure what the security problem is with exec() in Workers, since they already let me run any code I upload, but you can’t use it, and I assume it’s just because I don’t understand the problem space.

I do understand the problem with code size, though, because Cloudflare is deploying your code everywhere. It’s a real limitation that we have to deal with at this point. Your code isn’t sitting on one server somewhere, it’s being deployed to all of Cloudflare’s datacenters, and there has to be some limit to that.

Thank you for your kind answer.

SSR gave up on Cloudflare.

This is because when using Workers, I suffer from size errors, and Pages only supports SSG.

I use SSG when hosting frontends on Cloudflare.

I mean, I already stated if you can do SSR on Workers you can do it on Pages. If you couldn’t get that working, I’d love to hear why

If you can’t do it on Workers then yeah sure it wouldn’t work on Pages. But it sounds like you did get it to work but have too many assets for the Worker.