OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Where should I refresh my JWT in SvelteKit

  • Thread starter Thread starter ViFo
  • Start date Start date
V

ViFo

Guest
I'm trying to implement JWT authentication in a SvelteKit-app and I'm having trouble with where in the code I should refresh my accesstoken on site-reload. According to what I have found I should store the JWT in memory and then have a refresh-token that is stored as a HTTP-only cookie. When the page is reloaded or opened in a new tab, I need to call my backend to see if the refresh-token is valid or not, if it is, I will generate a new JWT and return it to the client.

Where is a good idea to make this call? I was thinking that the getSession-hook would be a good place but I'm not able to use fetch from there.

<p>I'm trying to implement JWT authentication in a SvelteKit-app and I'm having trouble with where in the code I should refresh my accesstoken on site-reload.
According to what I have found I should store the JWT in memory and then have a refresh-token that is stored as a HTTP-only cookie. When the page is reloaded or opened in a new tab, I need to call my backend to see if the refresh-token is valid or not, if it is, I will generate a new JWT and return it to the client.</p>
<p>Where is a good idea to make this call? I was thinking that the <code>getSession</code>-hook would be a good place but I'm not able to use <code>fetch</code> from there.</p>
 

Latest posts

S
Replies
0
Views
1
Safwan Aipuram
S
Top