I have a nextjs
using app
dir.
The app suport multi language: /[lang]/<router>
.
The [lang]
is reqiured for all route and only have some language.
I want to validate the [lang]
is correct. If not, show not-found.tsx
.
The app
support not-found.tsx
so I dont want to create an 404/page.txs
or _404/page.tsx
or some thing similer.
I want to handle in middleware.ts
.
Ex: I support 2 language : en
and vi
. The route shold be /en/<route>
or /vi/<route>
.
If user access to some thing like /abc
or /xyz/foobar
, not-found.tsx
sould be display.
How can I do that?