I have noticed that shallow routing breaks whenever using any middleware on Next.js13 and hard reloads the page if any middleware is processed even if the middleware is simple and does nothing like
`
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
This is for every route if I used export const config = { matcher: '/:path*', };
However if I change the matcher to export const config = { matcher: '/((?!_next)*)', };
omitting every _next path then it does shallow routing properly for every route except the root path / which is hard reloads every time, even if the user is already on /
Add a bulleted list, <Ctrl+Shift+8>Add a numbered list, <Ctrl+Shift+7>Add a task list, <Ctrl+Shift+l>
Directly mention a user or teamReference an issue or pull request
Add heading textAdd bold text, <Ctrl+b>Add italic text, <Ctrl+i>Add a bulleted list, <Ctrl+Shift+8>Add a numbered list, <Ctrl+Shift+7>Add a task list, <Ctrl+Shift+l>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
-
I have noticed that shallow routing breaks whenever using any middleware on Next.js13 and hard reloads the page if any middleware is processed even if the middleware is simple and does nothing like
`
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(request: NextRequest){
const response = NextResponse.next({
request: request,
})
return response;
}`
This is for every route if I used
export const config = { matcher: '/:path*', };
However if I change the matcher to
export const config = { matcher: '/((?!_next)*)', };
omitting every _next path then it does shallow routing properly for every route except the root path / which is hard reloads every time, even if the user is already on /
Beta Was this translation helpful? Give feedback.