Nuxt 3: Accessing tokens stored in localStorage from server-side

I’m attempting to implement a logout function that runs on the server-side. This function currently only removes tokens stored in localStorage upon login, as shown below:

const logout = () => {
  localStorage.removeItem('accessToken');
  localStorage.removeItem('idToken');
};

However, this approach encounters an error since localStorage is inaccessible on the server-side.

Question:#

How can I effectively remove the ‘accessToken’ and ‘idToken’ stored in localStorage from the server-side?

In the context of Nuxt 3 and removing tokens from localStorage on the server-side, I haven’t directly tried modifying localStorage because it’s not accessible there.

What I expected:

I expected the logout function to successfully remove the tokens (accessToken and idToken) from localStorage on the server after a successful logout, as it does on the client-side. This would effectively invalidate the user’s session.