Serving Next.js assets from Caddy is faster than letting a JavaScript runtime do all the work.

Of course this depends on your desired deployment if you are using Vercel you can safely ignore this optimization.

I use Kubernetes so this is how I configure Caddy to do the work.

domain.com {
    # Serve Next.js static assets (_next/static) if not handled by Node
    handle_path /_next/static/* {
        root * /srv/.next/static
        file_server
    }

    # Reverse proxy the rest to the Next.js Node server
    handle {
      encode gzip
      root * /srv/public
      rewrite @try_files {http.matchers.file.relative}
      file_server
      reverse_proxy http://userui {
          # If the server set a cookie, forward it to the client
          @authCookie header Set-Cookie *
          header_down @authCookie Set-Cookie {header.Set-Cookie}
        }
    }
}