My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
K Srinivas Rao

78 likes

·

11.2K reads

16 comments

Ahmad Yousif
Ahmad Yousif
Nov 14, 2022

I would do it slightly differently, I would send the rT in a cookie instead of sending it in the response , and in the frontend I resend this cookie on every request for protected route back to the backend and compare it's value with the original rT sent upon authentication which would be stored in the db, and maybe not storing the tokens in the local storage but rather in the memory.

6
·
·1 reply
K Srinivas Rao
K Srinivas Rao
Author
·Nov 15, 2022

Ah, yes.. Great suggestion... It's never a good idea to store the tokens on frontend. But I wanted to explain only the frontend side of the authentication in a visual manner, that's why I went with it. I'll explore the full stack side of it another day in a more secure way.

2
·
Tyler
Tyler
Nov 14, 2022

I would appreciate if you could go into the backend as well 🙃. Great article!

2
·
·1 reply
K Srinivas Rao
K Srinivas Rao
Author
·Nov 15, 2022

Sure, coming soon...

·
Gokul Gopi
Gokul Gopi
Nov 22, 2022

Everything was explained pretty nicely. Now I have much more clarity around this topic 👍. Waiting for the backend part..

1
·
Gabhan O'Loughlin
Gabhan O'Loughlin
Apr 14, 2023

The axiosInstance.ts file no longer works with the latest React Query / Typescript (April 2023). Hopefully you can update the article. As someone who is new to React, your approach makes total sense to me, but I'm struggling to figure out how to make it work.

1
·
·1 reply
K Srinivas Rao
K Srinivas Rao
Author
·Sep 4, 2023

Hi Gabhan,

I'll be writing a series of articles on production grade authentication which is going to cover everything in depth with the latest tools and patterns, stay tuned!

·
Dennis Githinji Wakahia
Dennis Githinji Wakahia
Jan 4, 2023

nn

·
Damilola Ogunboyejo
Damilola Ogunboyejo
Apr 3, 2023

Hi K Srinivas Rao, can I get your email please, I need help with react query and nextjs

·
·1 reply
K Srinivas Rao
K Srinivas Rao
Author
·Sep 4, 2023

You can find it on my blog profile

·
Oussama Moutafatin
Oussama Moutafatin
May 2, 2023

The try-catch inside the interceptor does not catch anything, the interceptor keeps looping within itself

·
·1 reply
K Srinivas Rao
K Srinivas Rao
Author
·Sep 4, 2023

Hey,

I'll be writing a series of articles on production grade authentication which is going to cover everything in depth with the latest tools and patterns, stay tuned!

10
·
Игорь Чехунов
Игорь Чехунов
Jul 4, 2023

если можно версию с куки, аксес рефреш токен, с защитой роутов и с тайпскриптом.

·