Next.js Discord

Discord Forum

Issue with req.nextUrl.pathname

Answered
Dutch posted this in #help-forum
Open in Discord
DutchOP
Using "req.nextUrl.pathname" for the root page, it is only returning "/meta.json"
Answered by aardani
well wouldnt that only match the non-directory files? i.e css and stuff :v
View full answer

18 Replies

did you have any export const matcher?
DutchOP
this is my config
well wouldnt that only match the non-directory files? i.e css and stuff :v
Answer
try removing the config matcher
(or commenting)
DutchOP
oh, it actually worked. I need to review my matcher. Thanks a lot mate
i think you just need to negate it xD
it matches the opposite of what the comment said
DutchOP
yeah makes sense HAHA 😅
DutchOP
using this regex '/((?!api|static|.\..|_next).*)' i am able to exclue static files and the api. I can get the pathname for every single page, expect the home page :/
im also confused since im pretty sure you got that from next.js docs and ure saying it doesn't work
if you could, you can investigate if its a bug or not
DutchOP
looks like this worked
wouldn't / match ALL routes?
DutchOP
it is, but the first statement is excluding all _next/* (like, static files, api, etc)
ah i see
if it works then it works :derp:
DutchOP
:noice: