Nx: @nrwl/next does not pickup new v10 Internationalized Routing (i18n object in next.config.js)

Created on 6 Nov 2020  路  5Comments  路  Source: nrwl/nx

Current Behavior


@nrwl/next does not pickup new v10 Internationalized Routing (i18n object in next.config.js)

Expected Behavior



Vercel added Internationalized Routing (i18n object in next.config.js) in Next v10.
When I add an i18n configuration object in next.config.js I excpect that the Next app in Nx is picking it up and activates v10 Internationalized Routing.

Steps to Reproduce

  1. In an empty Nx workspace create a Next app :
nx g @nrwl/next:app web

  1. in /apps/web/next.config.js add the i18n configuration object as per the official docs
 module.exports = {
  i18n: {
    locales: ['en', 'fr', 'nl'],
    defaultLocale: 'en',
  },
};

  1. launch the Next app and try to navigate to /nl or /fr : This should display the Index Page, but it renders 404 instead.
nx serve web




Failure Logs

Environment


NX Report complete - copy this into the issue template

nx : Not Found
@nrwl/angular : Not Found
@nrwl/cli : 10.3.0
@nrwl/cypress : 10.3.0
@nrwl/eslint-plugin-nx : 10.3.0
@nrwl/express : Not Found
@nrwl/jest : 10.3.0
@nrwl/linter : 10.3.0
@nrwl/nest : Not Found
@nrwl/next : 10.3.2
@nrwl/node : Not Found
@nrwl/react : 10.3.0
@nrwl/schematics : Not Found
@nrwl/tao : 10.3.0
@nrwl/web : 10.3.0
@nrwl/workspace : 10.3.0
typescript : 4.0.3

nextjs bug

All 5 comments

@pmualaba For what I can see @nrwl/next use "next": "^9.3.3". Since i18n is a v10 feature I think is expected to not work. I would not tag as a bug.

If you add next v10 in your project i18n will work works (for what I've seen with a quick test).

I also have a problem with Internationalized Routing.

If I run a build though NX as: ./node_modules/.bin/nx serve app --prod
"/" route without a locale prefix (next uses default locale in this case) works correctly

If I go to dist folder, install dependencies and run through NPM as: npm start
"/" route without a locale prefix returns 404

Seems like next.config.js is not copied on build to dist folder

Seems like next.config.js is not copied on build to dist folder

If I copy next.config.js to dist folder, routing works correctly.

I have created a PR #4179 that should resolve this issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZempTime picture ZempTime  路  3Comments

SWGeekPD picture SWGeekPD  路  3Comments

Koslun picture Koslun  路  3Comments

about-code picture about-code  路  3Comments

elliotmendiola picture elliotmendiola  路  3Comments