refinedev / refine

A React Framework for building internal tools, admin panels, dashboards & B2B apps with unmatched flexibility.
https://refine.dev
MIT License
27.54k stars 2.14k forks source link

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

Closed pguijas closed 4 months ago

pguijas commented 4 months ago

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

BatuhanW commented 4 months ago

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.