YuliyaMinsk
Best Practices for Nuxt 3 + JWT + Pinia + TanStack Query Integration
Thank you, Jacek, for all the valuable advice! I've implemented a setup where server routes handle login, logout, refresh, and check operations, calling the backend accordingly. The tokens are stored encrypted in cookies, and everything is functioning well.
However, I’m now facing a challenge where I need to add the access token to each request that the application makes to the backend. Since the tokens are stored in cookies on the server, I can't access them in useCustomFetch.
Should I make a proxy request in the server route, add the token to the header there, and then send it to the backend in this modified form? Or should I add a middleware to handle it? What would you recommend?
18 replies
Best Practices for Nuxt 3 + JWT + Pinia + TanStack Query Integration
I understand your point, which is why I plan to move the tokens to cookies and store them in an encrypted form. Unfortunately, at this stage, I can't change the technology stack, so I need to find a way to implement authentication using tokens.
18 replies
Best Practices for Nuxt 3 + JWT + Pinia + TanStack Query Integration
Thank you for your response. I appreciate the perspective you've shared. To clarify, this is a commercial project that I'm working on. While I'm still new to Nuxt 3, I have some experience with React. The backend endpoints for login, logout, and token refresh were prepared by our backend developers, and now it's my responsibility to implement the frontend.
Given the commercial nature of this project, my main goal is to implement a robust and secure authentication system using JWT.
I'm open to any suggestions on how to improve my current approach or best practices you might recommend. My priority is to create a reliable setup that can handle authentication efficiently, while also considering the potential for future expansion and development.
18 replies