Repository: next.js
Issue: Static export with skipTrailingSlashRedirect results in invalid request paths for RSC payload .txt files
Labels: create-next-app,Output (export/standalone),Navigation,Runtime,Pages Router

### Link to the code that reproduces this issue

https://github.com/klittlepage/next-skip-trailing-slash-rsc-bug

### To Reproduce

1. `next build`
2. Serve the resulting `out` directory
3. Navigate to the site root and note failed requests for rsc text files, e.g., http://localhost:8000/fails.txt?_rsc=1ld0r

### Current vs. Expected behavior

The routes generated by [createFetch](https://github.com/vercel/next.js/blob/35acd7e1faae66feddeffe6362fae9fb5a5b1281/packages/next/src/client/components/router-reducer/fetch-server-response.ts#L249) should take `skipTrailingSlashRedirect` into account, e.g., `http://localhost:8000/fails/index.txt?_rsc=1ld0r`.



### Provide environment information

```bash
Node.js v20.18.0

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:05:23 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6031
  Available memory (MB): 36864
  Available CPU cores: 14
Binaries:
  Node: 20.18.0
  npm: 10.8.2
  Yarn: N/A
  pnpm: 9.15.0
Relevant Packages:
  next: 15.1.1-canary.23 // Latest available version is detected (15.1.1-canary.23).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.3.3
Next.js Config:
  output: export
```


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

create-next-app, Navigation, Output (export/standalone), Pages Router, Runtime

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

next build (local), Other (Deployed)

### Additional context

Related: https://github.com/vercel/next.js/issues/73427

The fix proposed by @yukiyokotani in https://github.com/vercel/next.js/pull/73912, in conjunction with the patch below, resolves the issue. NB: the patch is against: https://github.com/yukiyokotani/next.js/tree/fix-static-export-rsc-payload-path.

```patch
diff --git a/packages/next/src/client/components/router-reducer/fetch-server-response.ts b/packages/next/src/client/components/router-reducer/fetch-server-response.ts
index 02545c4ddb..7b25952dec 100644
--- a/packages/next/src/client/components/router-reducer/fetch-server-response.ts
+++ b/packages/next/src/client/components/router-reducer/fetch-server-response.ts
@@ -11,6 +11,8 @@ const { createFromReadableStream } = (
       require('react-server-dom-webpack/client')
 ) as typeof import('react-server-dom-webpack/client')
 const basePath = (process.env.__NEXT_ROUTER_BASEPATH as string) || ''
+const skipTrailingSlashRedirect =
+  (process.env.__NEXT_MANUAL_TRAILING_SLASH as boolean) ?? false

 import type {
   FlightRouterState,
@@ -230,7 +232,7 @@ export function createFetch(

   if (process.env.NODE_ENV === 'production') {
     if (process.env.__NEXT_CONFIG_OUTPUT === 'export') {
-      if (fetchUrl.pathname === basePath) {
+      if (fetchUrl.pathname === basePath || skipTrailingSlashRedirect) {
         fetchUrl.pathname += '/index.txt'
       } else if (fetchUrl.pathname.endsWith('/')) {
         fetchUrl.pathname += 'index.txt'
```