strangeQuirks
strangeQuirks

Reputation: 5940

Using createServerComponentClient from supabase in NextJS when deployed to prd causes a 404

I have the page in NextJS-13: /app/test/page.tsx that simply shows Hello world. (deployed to vercel) Within the /test directory I also have a layout.tsx.

Now when I use createServerComponentClient from import { createServerComponentClient } from '@supabase/auth-helpers-nextjs'; in it, i get a 404. On my dev server (localhost) it works fine however (I see the page without a 404).

layout.tsx:

import { ReactNode } from 'react';

import { createServerComponentClient } from '@supabase/auth-helpers-nextjs';
import { cookies } from 'next/headers';

export default async function Layout({ children }: { children: ReactNode }) {
  const supabase = createServerComponentClient({ cookies });
  return <div>{children}</div>;
}

When I remove createServerComponentClient it works (no 404).

I also have the middleware.ts as mentioned here: https://supabase.com/docs/guides/auth/auth-helpers/nextjs

Any ideas why?

Upvotes: 0

Views: 1669

Answers (1)

strangeQuirks
strangeQuirks

Reputation: 5940

So the issue was in my next.config I had this which breaks routing

i18n: {
    locales: ['en'],
    defaultLocale: 'en',
  }

Upvotes: 0

Related Questions