Closed CareTiger closed 1 year ago
This warning is coming from the "@supabase/supabase-js" package. Because the "persistSession" is not set. For more information: https://supabase.com/docs/reference/javascript/release-notes
Add to your nuxt.config.ts the following:
supabase: {
client: {
auth: {
persistSession: false //or true
}
}
}
After this change the warning is gone.
@maximilian-schwarz what are the implications of setting persistSession
to true or false?
What was the default behaviour before?
This warning is coming from the "@supabase/supabase-js" package. Because the "persistSession" is not set. For more information: https://supabase.com/docs/reference/javascript/release-notes
Add to your nuxt.config.ts the following:
supabase: { client: { auth: { persistSession: false //or true } } }
After this change the warning is gone.
You might do some thorough testing with that. I haven't delved into the code, but the library may be relying on this being true for the browser client.
CC: @mitjans
Yeah, this line would need persistSession to be true for the browser client.
https://github.com/nuxt-modules/supabase/blob/main/src/runtime/plugins/supabase.client.ts#L32
And if you're calling getSession at all in your own code, it would fail as well.
Looks like this was resolved in release 0.3.6
resolved in release 0.3.6.
same problem on latest version: 0.3.6
same problem on latest version: 0.3.6
- Operating System: Darwin
- Node Version: v18.16.0
- Nuxt Version: 3.5.2
- Nitro Version: 2.4.1
- Package Manager: yarn@1.22.19
- Builder: vite
- User Config: ssr, nitro, experimental, runtimeConfig, app, modules, piniaPersistedstate, css, tailwindcss, supabase
- Runtime Modules: @pinia/nuxt@0.4.11, @pinia-plugin-persistedstate/nuxt@1.1.1, @nuxtjs/supabase@0.3.6, @nuxtjs/tailwindcss@6.7.0, @vueuse/nuxt@10.1.2, nuxt-icon@0.4.1
Build Modules: -
@tidusvn05 can you try 0.3.7? Someone found another portion of code which needed changed.
Thank for your feedback.
i was upgrade, but problem still exist.
@tidusvn05 do you mind creating a new issue and showing your code for creating all of your supabase clients?
I'm still getting this error despite putting the code in my nuxt.config.js.
const supabase = createClient
hi im from the future :3
@didim1 yes that did the trick! So you need to set it in each file you're using createClient() in, NOT in the nuxt.config.js file
@didim1 it really worked indeed. Thanks for this.
Can anyone explain what persistSession
does? In which case does it persist the session? Whats better for me, true or false?
Can anyone explain what
persistSession
does? In which case does it persist the session? Whats better for me, true or false?
When true
, it uses a storage implementation supported by supabase - whether built-in or custom; which holds auth info.
When false
, it uses memory to hold this info.
But when its true or not even used it stores the token in localStorage but why i'm still getting this error? Setting to false does not make sense because you wont get your token in localStorage
But when its true or not even used it stores the token in localStorage but why i'm still getting this error? Setting to false does not make sense because you wont get your token in localStorage
This would be unusual. Possible, I'm sure. Would need to see some code.
But when its true or not even used it stores the token in localStorage but why i'm still getting this error? Setting to false does not make sense because you wont get your token in localStorage
This would be unusual. Possible, I'm sure. Would need to see some code.
Yep sorry i'm using Next.js and forgot to set file use client
Or maybe i'm wrong im still testing this, damn so confusing
Basically in Next.js using client component in useEffect i'm calling await db.auth.getSession()
and i get this error message, but only get this once after i started dev server, when doing refresh i dont get this printed anymore, but if i kill and start again then i get
No storage option exists to persist the session, which may result in unexpected behavior when using auth.
If you want to set persistSession to true, please provide a storage option or you may set persistSession to false to disable this warning.
I'm also using Nextjs and I also find it confusing 😅
So noticed, that because i have createClient not in useEffect then i get this issue and it does not matter that i have set component as client, but when i add this createClient in useEffect then it works fine, so go figure. Next.js is really becoming unstable
I have tested this on SolidStart getting same issue. It looks to me that for split second it tries to run the code on Server hence the error but i'm not really sure if this maybe is a package problem than framework?
I had the same issue and managed to get it working. I saw in another post related to running Supabase locally that there was an issue with supabase/studio:0.23.06. As such, if you fork https://github.com/supabase/cli and change line 23 in internal/utils/misc.go
from StudioImage = "supabase/studio:v0.23.06"
to StudioImage = "supabase/studio
, run go build -o supabase .
to build the binary file and then copy it over the existing node_modules/supabase/bin/supabase
in your project and you should be good to go. Be sure to run npx supabase stop --no-backup
before you run npx supabase start
again. Not a real "fix" but it should get you up-and-running
Feel free to grab the updated binary or source from my fork to build it yourself: https://github.com/toddsampson/cli
This is really annoying because it's unclear whether it crashes the code or not, make debugging very painful
I use it in /app/something/router.ts
:
import { Database } from '@/types_db';
import { createClient } from '@supabase/supabase-js';
export const runtime = 'edge'
const supabase = createClient<Database>(
process.env.SUPABASE_URL!,
process.env.SUPABASE_KEY!,
);
export async function GET(req: Request) {
}
Such a mess to know which client use in different context, got to try 10 different ways to create the client both in local and deployed on vercel and see if it work or not 😆😭
@louis030195 based on what I see in your code, you're running the client on the server-side. And since you're not using auth helpers here, or custom storage, you should be setting these three auth options for your client.
const options = {
auth: {
persistSession: false,
autoRefreshToken: false,
detectSessionInUrl: false
}
}
How this helps:
{
global: { headers: { Authorization: req.headers.get("Authorization")! } },
auth: {
detectSessionInUrl: false,
autoRefreshToken: false,
persistSession: false,
}
}
seeing this warning/information on starting the dev server. Not sure of the implications and what action needs to be taken. FYI - discussion thread on Supabase - Discord server
No storage option exists to persist the session, which may result in unexpected behavior when using auth. If you want to set persistSession to true, please provide a storage option or you may set persistSession to false to disable this warning.
my nuxi info-