NextJS Preview 414 Request-URI Too Large


We are using old preview integration which is working as expected, but for some of our pages, we start getting 414 error from prismic API.

Our dependencies

"@prismicio/client": "6.0.0",

// Preview API

import * as prismic from '@prismicio/client'
import { linkResolver } from 'prismic/LinkResolver'
import { serialize } from 'cookie'

const Preview = async (req, res) => {
  const { token, documentId } = req.query
  const endpoint = prismic.getEndpoint(repoName)
  const client = prismic.createClient(endpoint, {


  const redirectUrl = await client.resolvePreviewURL({
    defaultURL: '/',
    documentID: documentId,
    previewToken: token

  res.setHeader('Set-Cookie', serialize('Preview_url', req.url, { path: '/' }))
  res.setPreviewData({ ref: token })
  res.writeHead(302, { Location: `${redirectUrl}` })

My response from prismic server looks like this

error - PrismicError: An invalid API response was returned
    at Client.fetch (.../website-next/node_modules/@prismicio/client/dist/index.js:475:15)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Client.getFirst (.../website-next/node_modules/@prismicio/client/dist/index.js:244:20)
    at async Client.getByUID (.../website-next/node_modules/@prismicio/client/dist/index.js:279:12)
    at async query (webpack-internal:///./node_modules/next-slicezone/features/query.js:14:10)
    at async eval (webpack-internal:///./prismic/hooks/enrichedGetStaticProps.ts:55:17)
    at async Object.renderToHTML (.../website-next/node_modules/next/dist/server/render.js:386:20)
    at async doRender (.../website-next/node_modules/next/dist/server/base-server.js:687:38)
    at async cacheEntry.responseCache.get.isManualRevalidate.isManualRevalidate (.../website-next/node_modules/next/dist/server/base-server.js:796:28) {
  url: '',
  response: undefined,
  page: '/blog/[uid]'

Big thanks in advance.

Screenshot 2022-11-17 at 13.32.50

Hello, @Phil and @Pau maybe you have any information about this issue?
We are getting the same errors trying to build new pages.

Hi Arnas,

Are you using GraphQuery in your blog post queries?

Hello, @Phil,

Short answer - I think no.
Long answer - We are using next-slicezone, which uses @primisc/client under the hood. So If I understand correctly I should use REST API.

Sorry if I wasn't clear; GraphQuery is the query option used in our REST API to get content from a linked document. So it's not GraphQL.

I ask because the URL is too long, causing the error and this usually comes from GraphQL.

Saying that I can see you're using Fetch Links from your URL (&fetchLinks=) so you're not using GraphQuery.

What I can also see in your URL (&routes=) is that you're using the Route Resolver with a lot of entries, so my guess is that this is causing the URL too long error. Request URLs to the Rest API are limited to 2048 characters. You can reduce your string length by using line breaks with no spaces or tabs, or you can use a white space removal tool.

So having no whitespace in your Routes definition should solve this issue.


Thank you for your answer @Phil.

This solution is temporary because our repo is growing fast. What I did is migrated away from next-slicezone to recommended @prismicio/client, @prismicio/react, @prismicio/next and @prismicio/helpers

New integration build URL differently which solves our problem.
I hope this will be useful for others in the future.


Thanks for sharing your solution @juskeviciusarn this will definitely be useful for future users as your said.

I was unaware the old next-slicezone component had this issue.

Thanks again.