Authorization with External API
Hi all,
I'm working on a project that consists of a mobile application in React Native and a desktop application in NextJS. I was hoping to be able to share an API between these two applications, so I've built one in NestJS for this purpose.
I am trying to implement auth flow into a NextJS project. Currently, I am facing an issue: When I log in - I'm able to generate an access and refresh token just fine, but once it expires, I have to refresh twice because the refresh call doesn't appear ready in time prior to the API being called from the page component, thus resulting in an unauthorized error.
2 Replies
I’ve realized that this isn’t how it’s supposed to be done and I have to use something like tRPC as a “middleware” for my external api. Does anyone have an idea of what is best practice and an example?
Same issue is described here: https://github.com/vercel/next.js/discussions/48917
GitHub
Need refresh page to get the cookies set in Middleware · vercel nex...
Summary @ Using NextJS 13.3 with App Dir and API Routes. I am trying to build a auth system with my external backend nodeJS. Basically, front send credentials to backend, backend validate and retur...