Shallow option doesn’t work with middleware in the root of my project, ./src/middleware.ts
<Button onClick={() => router.push(‘/dashboard’, {}, { shallow: true })}>Dashboard
<NextLink href={‘/dashboard’} passHref shallow>Dashboard
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);
}
};
"next": "^12.3.4",
"next-translate": "^2.0.4",
"react": "^17.0.2",
"react-dom": "^17.0.2"