## The problem
Issue workos/workos-node#1184 (closed, 19 comments): Hi, 

We are using the Node SDK in our nextjs application. We are running into issues in relation to refreshing the tokens in middleware. 

Basically, when using something like tanstack query, and refocusing on the window, it will refetch the queries. We have some queries pointing to our API route handlers. This works okay, until the token needs to be refreshed, it then seems that my custom assert session helper doesn't pick up the session. Any ideas as to why?

This is working perfectly, until the refetch on window focus occurs and refresh token needs to be refreshed

```ts
export...

## What fixed it
Token refresh in Next.js middleware not picking up the session after window-focus refetches: this turned out to be a WorkOS API backend issue, not an SDK or middleware code problem, and was resolved by a backend change. No client-side code change needed; it should already be fixed server-side. Reopen the issue if it still occurs.