Dynamic pages take too long to open
What version of this package are you using?
"next": "^12.3.4", "next-translate": "^2.0.5", "react": "^17.0.2", "next-translate-plugin": "^2.0.5"
What operating system, Node.js, and npm version? MacOs: 13.3.1 Node: 18 npm v8.19.3
What happened?
I've updated next-translate from version 1.0.5 to 2.0.5. On vercel when deploying the project with the new version next-translate, the dynamic pages like [id].js are very long open the first time. For example:
src/pages/users.tsx
src/pages/users/[userId].tsx
next-translate - compiled page: /users - locale: en - namespaces: translation - used loader: getStaticProps
next-translate - compiled page: /users/[userId] - locale: en - namespaces: translation - used loader: getServerSideProps
There my next.config.js:
const nextTranslate = require('next-translate-plugin');
module.exports = nextTranslate({
webpack: (config, options) => {
//....
return config;
},
});
middleware.ts
import { NextResponse, NextMiddleware } from 'next/server';
const PUBLIC_FILE = /\.(.*)$/;
export const middleware: NextMiddleware = (req) => {
const acceptLanguage =
req?.headers?.get('accept-language') &&
req?.headers?.get('accept-language')?.slice(0, 2);
if (
req.nextUrl.pathname.startsWith('/_next') ||
req.nextUrl.pathname.includes('/api/') ||
PUBLIC_FILE.test(req.nextUrl.pathname)
) {
return;
}
if (req.nextUrl.locale === 'default') {
const newUrl = req.nextUrl.clone();
newUrl.locale = acceptLanguage || 'en';
return NextResponse.redirect(newUrl);
}
};
What did you expect to happen?
Dynamic pages open quickly as usual before the update.
Would be great if you create a reproducible example in a repo 😊 in this way we can investigate if this problem is related to the next-translate library or not. Thanks!
I'm having the same issue, for some reason it takes ages to load
Try:
-
next-translate- version2.3.0-canary.3 -
next-translate-plugin- version2.3.0-canary.6
(requires Next.js 13)