Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static export with skipTrailingSlashRedirect results in invalid request paths for RSC payload .txt files #74445

Open
klittlepage opened this issue Dec 31, 2024 · 5 comments · May be fixed by #73912
Labels
create-next-app Related to our CLI tool for quickly starting a new Next.js application. Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation. Output Related to the the output configuration option. Pages Router Related to Pages Router. Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@klittlepage
Copy link

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 should take skipTrailingSlashRedirect into account, e.g., http://localhost:8000/fails/index.txt?_rsc=1ld0r.

Provide environment information

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: #73427

The fix proposed by @yukiyokotani in #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.

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'
@klittlepage klittlepage added the bug Issue was opened via the bug report template. label Dec 31, 2024
@github-actions github-actions bot added create-next-app Related to our CLI tool for quickly starting a new Next.js application. Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation. Output Related to the the output configuration option. Pages Router Related to Pages Router. Runtime Related to Node.js or Edge Runtime with Next.js. labels Dec 31, 2024
@sh471

This comment was marked as spam.

@sh471

This comment was marked as spam.

@sh471

This comment was marked as spam.

@klittlepage
Copy link
Author

@sh471 this is unrelated.

@klittlepage
Copy link
Author

@yukiyokotani the patch into #73912 .

@samcx samcx removed the bug Issue was opened via the bug report template. label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-next-app Related to our CLI tool for quickly starting a new Next.js application. Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation. Output Related to the the output configuration option. Pages Router Related to Pages Router. Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
3 participants