Reputation: 103
I have the following code on my Dynamic Routing page [id] that I am trying to use with next-i18next translations. However, it is throwing an error when being deployed on Vercel (working locally). I am trying to use the fallback function with an empty path array to somehow accept all possible paths(?). In my console I am getting a statuscode 500 GET-error and a "Failed to load static props"-error.
It is working when I specify a specific id within getStaticPaths
and go to that matching path. However, I can't possibly specify thousands of ids for this to work. Shouldn't the fallback take care of this or how can I get past this?
export async function getStaticPaths() {
return {
paths: [], fallback: true
}
}
export async function getStaticProps(context) {
return {
props: {
params: context.params,
...(await serverSideTranslations(context.locale, ["common"])),
},
}
}
Update: This is the Vercel function log (xxxxx-values is some id's I removed)
[GET] /_next/data/xxxxxxxxxxx-y/en/packages/490713.json
20:26:37:98
2022-02-28T19:26:39.300Z xxxxxxxxxxxxxxxxxxxxx ERROR Error: ENOENT: no such file or directory, scandir '/var/task/public/locales/en'
at Object.readdirSync (fs.js:1047:3)
at getLocaleNamespaces (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:175:23)
at /var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:181:20
at Array.map (<anonymous>)
at getNamespaces (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:180:44)
at createConfig (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:221:29)
at _callee$ (/var/task/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:199:53)
at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:294:22)
at Generator.next (/var/task/node_modules/regenerator-runtime/runtime.js:119:21) {
errno: -2,
syscall: 'scandir',
path: '/var/task/public/locales/en',
page: '/packages/[id]'
}
RequestId: xxxxxxxxxxxxxxxxxxxx Error: Runtime exited with error: exit status 1
Runtime.ExitError
Upvotes: 2
Views: 2871
Reputation: 103
This line was missing in my next-i18next-config
localePath: path.resolve('./public/locales'),
Upvotes: 4