Next.js: Local sub-route with param renders 404 in production app

Created on 28 Oct 2020  路  10Comments  路  Source: vercel/next.js

I have a route with a param (/src/pages/items/[id].tsx), and am testing the built-in i18n routing.

// next.config.js
module.exports = {
  i18n: {
    locales: [
      'fr',
      'en-US',
    ],
    defaultLocale: 'fr'
  }
};

The app renders correctly the page /en-US/items/0 in local. However, in production it returns a 404 (app hosted on Vercel). If I navigate to this url from within the app, it works correctly though. It really happens with routes with params, a page /en-US/items renders fine.

Is it a bug or I am doing something wrong ?

bug 3

Most helpful comment

Alright, it works now ! Thanks ! 馃敟馃敟馃敟

All 10 comments

I got the same issue today. Hope this got fixed soon.

Hi, can you provide a reproduction showing the unexpected 404? We have tests for i18n and dynamic pages on Vercel which are currently passing as expected.

@ijjk I put together the reproducion here

The source code is here

As you see, the /items/1 link is 404.

In case i remove the i18n from next.config.js, the link /items/1 works as normal.

Experiencing the same issue. In my case I have the following folder structure: src/pages/company/[companyId].tsx. Visiting /company/[companyId] renders the correct page (with router.query.companyId being [companyId]), but visiting /company/1 results in a 404.

Hi, this should now be corrected, please re-deploy your application and give it a try!

Alright, it works now ! Thanks ! 馃敟馃敟馃敟

It seems like this is fixed only for Vercel deployments. I am still experiencing the same issue, running an application with next start.

Running yarn build && yarn start with this repro and visiting /post/1 directly results in a 404, but using the link to /post/1 from / renders the dynamic route.

The same app deployed to Vercel works as expected.

This should be corrected for next start in the latest canary of Next.js v10.0.2-canary.5, please upgrade and give it a try!

Seems to work fine after upgrading. Thanks 馃帀

Was this page helpful?
0 / 5 - 0 ratings