I have a next.js 13.4.9 website using the app router. I’m using middleware for internationalization. And I’m using SSG with ISR.
Everything works except one thing. If I navigate with the Url, middleware is executed as expected. But when navigating through next/link, middleware is not executed. I know this because I’m cheking the edge function logs. How can I fix it?
The website url is:
One way to check that the middleware works is the following. If you access this url:
the url will be rewritten to
To check that navigating through next/link won’t trigger middleware you can click on the “català” button in the header, and you’ll be brought to
https://internationalized-test.netlify.app/ca. This time, though, the url won’t be rewritten and it will stay as is.
I’ve realized that the problem only occurs when I’m doing SSG and ISR, without these, next/link works as expected.