Normally this error is pretty easy to spot, but the error message is telling me that one of two functions do "use client"; when in fact they dont. I just created a super simple API endpoint in pages/api/invite.ts which looks like this:
invite.ts
`import type { NextApiRequest, NextApiResponse } from 'next';
import { createServerClient } from '../../utils/supabase-server';
import { UserResponse } from '@supabase/gotrue-js/dist/module/lib/types';
export default async function handler(req: NextApiRequest, res: NextApiResponse<void>) {
// do stuff
}`
Then i have my supabase client:
`import 'server-only';
import { headers, cookies } from 'next/headers';
import { createServerComponentSupabaseClient } from '@supabase/auth-helpers-nextjs';
import { Database } from '../db_types';
export const createServerClient = () =>
createServerComponentSupabaseClient<Database>({
headers,
cookies,
});`
Now when requesting this API endpoint from the frontend i get this famous error (see screenshot) where he tell me that either invite.ts or supabase-server.ts uses the "use client" flag, which is wrong. Dont have any clue how to get rid of it. Thanks for any hint.