Skip to content

[Pages] Page instead of 404 is rendered when fallback: false and paths: [] when using getStaticProps and getStaticPaths in development #80071

@FabianKoder

Description

@FabianKoder

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/nostalgic-fermat-gqntzv

To Reproduce

  1. Go to path /cms/test in reproduction
  2. Page renders -> crash because required property data is not provided
  3. Add at least one random unrelated page to paths in getStaticPaths, for example /cms/test2
  4. Visiting /cms/test again will now display a 404 page, as expected

Current vs. Expected behavior

While this is not a big issue overall, since it seemingly only affects development, this cost me quite some time trying to debug the issue and root cause because the expected and described behavior does not match with the real-world behavior.

According to the docs, "{ fallback: false } means other routes should 404", which means if no paths are provided (in this case the reason was setting up a fresh CMS with zero published paths available), all pages matching with the dynamic page should display the 404 page. This works as expected if there is at least one path provided - zero paths though result in the page being rendered as if it existed, but since getStaticProps is never called, there are no available props and the page will crash (depending on the implementation of course).

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.4.0-canary.61 // Latest available version is detected (15.4.0-canary.61).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

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

Pages Router, Dynamic Routes

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

next dev (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions