Builder returned invalid routes: should NOT be longer than 4096 char

It’s very much the same discussion as #8676, albeit with a new insight. I’ve also posted this in GitHub discussions at Error: Builder returned invalid routes: should NOT be longer than 4096 characters · vercel/vercel · Discussion #13283 · GitHub

My codebase has an extensive Content Security Policy (CSP) setup. I.e. many HTTP headers. Vercel is therefore giving the error ‘Builder returned invalid routes: should NOT be longer than 4096 characters’ during Vercel builds.

Please consider this discussion as a feature request and opportunity to help others.

  • I would expect this error to happen on localhost in a next build since the Vercel-Next.js relation is strong.
  • My solution was to relax the CSP config. Instead of listing hardcoded domains, I’ve basically reverted to a ‘allow most’ setup. I think Vercel’s technical setup should NOT reduce security.

The reason for the many CPS entries is the Google Tag Manager requirement to list all Google TLDs. See Use Tag Manager with a Content Security Policy  |  Tag Platform  |  Google for Developers

Hey @ddeleeuw. I moved this topic over to Feedback and shared with the team

1 Like