middleware matcher to ignore public folder
Answered
Cape lion posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Cape lionOP
export const config = { matcher: [ '/((?!api|_next).*)' ]};
I'm working on implementing i18n in my project, and want to prevent the middleware from triggering on
/*.svg
and /*.png
. How can I add this to the middleware matcher?Answered by B33fb0n3
@Cape lion you can do this by adding a if-phrase into your middleware. It could look like this:
Of you can change the
if (['/manifest.json', '/icon.png', ...].includes(pathname) || pathname.startsWith("/yourfolder"))
return;
Of you can change the
startsWith
part with endsWith to check the end of your requested files2 Replies
![Avatar](https://cdn.discordapp.com/avatars/301376057326567425/788b75eb8862277af3d31d317ada783f.webp?size=256)
B33fb0n3
@Cape lion you can do this by adding a if-phrase into your middleware. It could look like this:
Of you can change the
if (['/manifest.json', '/icon.png', ...].includes(pathname) || pathname.startsWith("/yourfolder"))
return;
Of you can change the
startsWith
part with endsWith to check the end of your requested filesAnswer
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Cape lionOP
Thanks