There are too many routes defined in your Layer0 routes.js file

I’m trying to deploy my Nextjs app to layer0, after run layer0 init and it generated default routes.js file, I then run layer0 deploy to deploy my app but it failed and said that “There are too many routes defined in your Layer0 routes.js file”
The default routes.js file contain nextRoutes middleware. If I remove this middleware then it deploy successfully. I can run normally on local but can not deploy.
Any idea about this? I’ve read through the docs but doesn’t see any limit number of routes.

The error message is a bit misleading. There isn’t an explicit limit on the number of routes, but rather a limit on the size of the edge logic generated by the router. By any change do you have a lot of files in the public directory?

If so, the issue is likely that Layer0 needs to create an edge route for each file. You can work around that by renaming “public” to “static” (so it’s no longer served by Next.js) and defining explicit routes in your routes.js based on the subdirectories in static.

So for example if you have:

    ...lots of files...
    ...lots of files...

You could serve them with the following route:

  .get('/images/:path*', ({ serveStatic }) => {
  .get('/scripts/:path*', ({ serveStatic }) => {

Yes my public folder contain a lots of files. I will try your suggestion above and let you know the result soon.
Thank you Mark.