Next.js Discord

Discord Forum

Using `getStaticPaths` with `fallback: false` w/ page router causes too many redirects in dev server

Answered
Japanese Bobtail posted this in #help-forum
Open in Discord
Japanese BobtailOP
When visiting a page that is not a provided static path, which should show the 404 page, the page crashes in chrome with the error that there were too many redirects.
E.g.
// for pages/discover/[tag].tsx
export const getStaticPaths: GetStaticPaths = () => ({
  paths: [
    { params: { tag: 'foo' } }
  ],
  fallback: false,
})

If I visit /discover/bar I would expect that I should see a 404 page, but it crashes saying there are too many redirects.
Answered by Japanese Bobtail
determined it's due to this redirect rule we have in place that's supposed to handle any requests missing our basePath of /app
{
  source: '/:path((?!app$|app/).*)',
  destination: '/app/:path',
  basePath: false,
  permanent: false,
},
View full answer

2 Replies

Japanese BobtailOP
ahhh it's not just the dev server, I tried doing a prod build and it has the same problem
Japanese BobtailOP
determined it's due to this redirect rule we have in place that's supposed to handle any requests missing our basePath of /app
{
  source: '/:path((?!app$|app/).*)',
  destination: '/app/:path',
  basePath: false,
  permanent: false,
},
Answer