Skip to content

Router is mistaking index route for a dynamic route with fallback #22750

@dennylouis

Description

@dennylouis

What version of Next.js are you using?

10.0.7

What version of Node.js are you using?

14.12.0

What browser are you using?

Chrome, Safari, Firefox

What operating system are you using?

macOS

How are you deploying your application?

Vercel

Describe the Bug

The Next.js router is mistaking the index.js route as a dynamic route with a query of "index".

I have 2 pages:
- pages/index.js
- pages/[page].js with fallback

Occasionally when loading the index route, I am getting directed to the [page].js route which is returning as an error page.
The router at this point is looking like this:

{
  "pathname": "/[page]",
  "route": "/[page]",
  "query": {
    "page": "index"
  },
  "asPath": "/",
  "components": {
    "/[page]": {
      "initial": true,
      "props": {
        "pageProps": {
          "preview": false,
          "pageData": {}
        },
        "__N_SSG": true
      },
      "__N_SSG": true
    },
    "/_app": {
      "styleSheets": []
    }
  },
  "isFallback": false,
  "basePath": "",
  "isReady": true,
  "isLocaleDomain": false,
  "events": {}
}

Expected Behavior

The index route should load consistently

To Reproduce

Create an index.js page and a dynamic route page with fallback: true.

Load the index route in the browser and refresh until it does not display.

My site can also be viewed for an example: https://cappellazzo-website-cvrquuxk8-homestudio.vercel.app/

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions