Repository: next.js
Issue: [NEXT-1162] Prefixing the default locale with middleware does not work on deployed vercel build
Labels: bug,Navigation,Runtime,linear: next

### Verify canary release

- [X] I verified that the issue exists in the latest Next.js canary release

### Provide environment information

```bash
Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64
    Binaries:
      Node: 18.12.1
      npm: 8.19.2
      Yarn: 1.22.18
      pnpm: 8.3.1
    Relevant packages:
      next: 13.3.5-canary.5
      eslint-config-next: 13.3.1
      react: 18.2.0
      react-dom: 18.2.0
```


### Which area(s) of Next.js are affected? (leave empty if unsure)

Middleware / Edge (API routes, runtime), Routing (next/router, next/navigation, next/link)

### Link to the code that reproduces this issue

https://github.com/VercammenJens/reproduction-next-vercel

### To Reproduce

Using `next-i18next` and applying the ["Prefixing the default locale"](https://nextjs.org/docs/advanced-features/i18n-routing#prefixing-the-default-locale) code from the documentation. In combination with `async rewrites()` in the `next.config`.

Have 2 pages, an index and another page (`move.tsx` in my example). Add a link from `next/link` in the index page to the other one. In the other page, put an api call that fetches data from an external data source in the `getStaticProps` and return this data in the `props`, and render this data in page.

Clicking the link redirects you to the page with an error displaying instead of the content. Upon refreshing this page, the content is displayed correctly.

Error text:

> Application error: a client-side exception has occurred (see the browser console for more information).

This bug only happens on deployed versions. If you `yarn build` + `yarn start`, this issue doens't happen. This is why I deployed this reproduction branch on a fresh vercel project using github to import it. This is the preview link for the deployed version on the main branch: [reproduction-next-vercel-git-main-jensverc.vercel.app](https://reproduction-next-vercel-git-main-jensverc.vercel.app/)

Preview of the bug in a video format with console open:

https://user-images.githubusercontent.com/19661051/235942139-3d02611a-29c8-4c1a-ae67-1cf14b6ea57c.mov

Preview of the bug in video format with network tab open, and looking at the prefetch.


https://user-images.githubusercontent.com/19661051/235943647-4993b90d-0717-4f34-82cf-6ee79af83621.mov

I've tried the workarounds posted here: https://github.com/vercel/next.js/issues/45904 but it doesn't work. Seems like a different issue as mine because my prefetched json has the correct data in it.


### Describe the Bug

Redirecting from one page to another with getStaticProps in the second page, doesn't trigger any fetch and returns undefined for all these props. It happens when you are using the default locale implementation from the Vercel documentation, in any deployed vercel build.

### Expected Behavior

Clicking a `next/link` to a SSG page with props in the page to open the page correctly with content fetched on build time. If the page has to revalidate it is supposed to get the correct data and either return the data or an empty array as written in the `getStaticProps`. This all on a deployed build on vercel, as it used to in `next@12`

### Which browser are you using? (if relevant)

Firefox 112.0 & Arc 0.101.2 with Chromium Engine Version 112.0.5615.137

### How are you deploying your application? (if relevant)

Default Vercel deploy

<sub>[NEXT-1162](https://linear.app/vercel/issue/NEXT-1162/prefixing-the-default-locale-with-middleware-does-not-work-on-deployed)</sub>