refinedev/refine

[BUG] Supabase token refresh not handled in Next.js example

pguijas opened this issue · 1 comments

Describe the bug

When automatically creating a project with npm create refine-app@latest using Next.js and Supabase, the authProvider creates a copy of the token created at login time. Cookies.set("token", data.session.access_token, {expires: 30, path: "/",});. This does not take into account the need to refresh the token (which supabase internally does in the client, storing it in local storage).

Remark that this token is used to check the auth:

check: async () => {
  const token = Cookies.get("token");
  const { data } = await supabaseClient.auth.getUser(token);
...

Steps To Reproduce

npm create refine-app@latest # (supabase and nextjs)

Expected behavior

Refresh the token.

Packages

@refinedev/supabase

Additional Context

No response

This is not a bug with Refine itself, however can be done as an improvement here.

Template is living in @pankod/superplate-core-plugins repository.