How would I check for a cookie on every request in nextjs?
问题 I have a nextjs app and I want to check every request to see if there is a JWT saved in their cookies. If not, I want to show them a login form. If they do have one, then proceed as normal. I can't think of where or how I would do this. Would I do this in pages/_app.js ? Is there some kind of middleware... thing? Hopefully I've explained what I want to accomplish, and someone can guide me to where or how I would do this. 回答1: If every page needs the token you should do it in the _app.js.