Repository: next.js
Issue: Server Side Exception during Production while implementing pagination and reading from search params. Application error: a server-side exception has occurred (see the server logs for more information). Digest: 163034583
Labels: bug,Output (export/standalone)

### Link to the code that reproduces this issue

https://github.com/Rahulg321/Law-Offices-of-Destiny-Aigbe

### To Reproduce

You can go to my code and start the application in dev mode and visit the blogs section. I am fetching my data using Prismic CMS and reading from search params so as to implement Pagination. The entire work flow works well in development mode but breaks during production when the side is deployed


**These are the error logs I am receiving during production**

`[Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
  digest: '163034583'
}`

```
F [Error]: Ref not found. Ensure you have the correct ref and try again. Master ref is: ZmCkDxEAAB4AxJSv
    at N.fetch (/var/task/.next/server/chunks/5367.js:1:12841)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async N.get (/var/task/.next/server/chunks/5367.js:1:5911)
    at async N.getByType (/var/task/.next/server/chunks/5367.js:1:7144)
    at async m (/var/task/.next/server/app/blogs/page.js:1:7240) {
  url: 'https://aigbelaw.cdn.prismic.io/api/v2/documents/search?q=%5B%5Bat%28document.type%2C+%22blogpost%22%29%5D%5D&page=1&pageSize=20&ref=Zl8-nBEAACAAwmIG&routes=%5B%7B%22type%22%3A%22homepage%22%2C%22path%22%3A%22%2F%22%7D%2C%7B%22type%22%3A%22page%22%2C%22path%22%3A%22%2F%3Auid%22%7D%5D',
  response: {
    type: 'api_notfound_error',
    message: 'Ref not found. Ensure you have the correct ref and try again. Master ref is: ZmCkDxEAAB4AxJSv'
  }
}
``` 


### Current vs. Expected behavior

The pagination works perfectly fine on development mode but breaks during production. I have included the error logs and full code details. I figure its due to the fact that I am using a mix of ssr and dynamic rendering.



### Provide environment information

```bash
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home Single Language
Binaries:
  Node: 20.10.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.1.0
  eslint-config-next: 14.1.0
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.5
Next.js Config:
  output: N/A
```


### Which area(s) are affected? (Select all that apply)

Not sure, Output (export/standalone)

### Which stage(s) are affected? (Select all that apply)

Vercel (Deployed)

### Additional context

This is the code I am using. I am thinking the error is in the way createClient is initialized using Prismic and how catching is configured there.


This is how createClient is initialized from Prismic
```typescript
import * as prismic from "@prismicio/client";
import * as prismicNext from "@prismicio/next";
import config from "./slicemachine.config.json";

/**
 * The project's Prismic repository name.
 */
export const repositoryName =
  process.env.NEXT_PUBLIC_PRISMIC_ENVIRONMENT || config.repositoryName;

/**
 * A list of Route Resolver objects that define how a document's `url` field is resolved.
 *
 * {@link https://prismic.io/docs/route-resolver#route-resolver}
 */
// TODO: Update the routes array to match your project's route structure.
const routes: prismic.ClientConfig["routes"] = [
  // Examples:
  {
    type: "homepage",
    path: "/",
  },

  {
    type: "page",
    path: "/:uid",
  },
];

/**
 * Creates a Prismic client for the project's repository. The client is used to
 * query content from the Prismic API.
 *
 * @param config - Configuration for the Prismic client.
 */
export const createClient = (config: prismicNext.CreateClientConfig = {}) => {
  const client = prismic.createClient(repositoryName, {
    routes,
    fetchOptions:
      process.env.NODE_ENV === "production"
        ? { next: { tags: ["prismic"] }, cache: "force-cache" }
        : { next: { revalidate: 5 } },
    ...config,
  });

  prismicNext.enableAutoPreviews({
    client,
    previewData: config.previewData,
    req: config.req,
  });

  return client;
};

``` 


![Screenshot (195)](https://github.com/vercel/next.js/assets/105978589/8fd48f90-26b7-42d0-9b79-add59fece748)
![Screenshot (196)](https://github.com/vercel/next.js/assets/105978589/21058ac4-f3f7-4b72-a6f2-3421c85f6f40)
![Screenshot (197)](https://github.com/vercel/next.js/assets/105978589/f0cf5d84-c6db-4efd-be6f-dd629d4c763c)
![Screenshot (198)](https://github.com/vercel/next.js/assets/105978589/fedd645b-7d21-4059-9a26-f574272ef08f)
![Screenshot (199)](https://github.com/vercel/next.js/assets/105978589/4ad232f0-e929-466e-9985-2d56afd13994)
![Screenshot (200)](https://github.com/vercel/next.js/assets/105978589/e085303c-c67b-4b15-8c00-98b89df79f8e)