middleware matcher to ignore public folder
Answered
Cape lion posted this in #help-forum
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
@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
Cape lionOP
Thanks