Open Jordaneisenburger opened 6 months ago
This also happens on a clean supabase / nextjs starter project (npx create-next-app -e with-supabase), the issue might not be directly supabase related in a sense that when you add a console.log('parent')
to app/page.tsx
in your application and then go ahead and do some tailwindcss changes to DeployButton.tsx
it will cause the parent to rerender and you will see the console.log
now if this parent server component were to do 2 db queries to supabase everytime you change css changes it will trigger the way to many /token requests making a very hard to work as you constantly hit the limits.
Too many /token
requests are indicative of a badly configured Next.js setup.
Please provide us with the middleware.ts
file.
Too many
/token
requests are indicative of a badly configured Next.js setup.Please provide us with the
middleware.ts
file.
responded in the support ticket
Bug report
Describe the bug
When doing a query to supabase using the createServerClient it causes /token to be requested 4 times. This causes Rate limit issues when for example on localhost I cntrl + reload the page 10 times quickly we already hit that limit
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
export function createClient() { const cookieStore = cookies()
return createServerClient( process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!, { cookies: { get(name: string) { return cookieStore.get(name)?.value }, set(name: string, value: string, options: CookieOptions) { try { cookieStore.set({ name, value, ...options }) } catch (error) { // The
set
method was called from a Server Component. // This can be ignored if you have middleware refreshing // user sessions. } }, remove(name: string, options: CookieOptions) { try { cookieStore.set({ name, value: '', ...options }) } catch (error) { // Thedelete
method was called from a Server Component. // This can be ignored if you have middleware refreshing // user sessions. } }, }, } ) }So from my observations it seems that
await supabase.auth.getUser();
causes 2/token
requests andawait supabase .from('profiles')
is doing 2 additional/token
requestsThe
/user
is also happening twice but this isn't causing problems for now but I don't think should happen either.Expected behavior
I'd expect the queries to only happen once