imbhargav5 / nextbase-nextjs-supabase-starter

πŸš€βš‘οΈ Free Boilerplate and Starter kit for Next.js 14+, Supabase, Tailwind CSS 3.2 and TypeScript. πŸš€ Next.js πŸ”₯ Supabase πŸ’» TypeScript πŸ’š ESLint 🎨 Prettier 🐢 Husky 🧹 Lint-Staged πŸ§ͺ Jest πŸ§ͺ Testing Library πŸ•ΉοΈ Playwright ✍️ Commitizen πŸ’¬ Commitlint πŸ’» VSCode πŸŒͺ️ Vercel 🎨 PostCSS πŸƒ Tailwind CSS βš›οΈ React Query
https://open-source-template.usenextbase.com
MIT License
549 stars 111 forks source link

Deployed to Vercel with 404 Not Found result #33

Open arbisyarifudin opened 3 months ago

arbisyarifudin commented 3 months ago

Hi, I use your template and added some pages and functionality. But when it is deployed to Vercel, it's always turned 404.

Please feel free to check this. https://fsc-sd-web2-git-develop-arbis-projects-2fa9c352.vercel.app?_vercel_share=kHsrmA32GvDt0CqRCW35ux0FMt1zTXcG

arbisyarifudin commented 3 months ago

Hi. I think the 404 not found is because i add vercel.json file in there. So i delete it and run the build again and but the result is: image https://fsc-sd-web2-git-main-test-arbis-projects-2fa9c352.vercel.app/?_vercel_share=AnHcaMF8drBKWMPKsTwqUI4uAPwHpIpQ

and the logs is:

TypeError: Cannot read properties of undefined (reading 'getSession')
    at m (/var/task/.next/server/app/(dynamic-pages)/(main-pages)/page.js:1:6628)
    at y (/var/task/.next/server/app/(dynamic-pages)/(main-pages)/page.js:1:6860)
    at eh (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:134786)
    at e (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:137671)
    at ek (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:138145)
    at Array.toJSON (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:135755)
    at stringify (<anonymous>)
    at eR (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:142219)
    at eE (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:142698)
    at Timeout._onTimeout (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:135475) {
  digest: '2243357109'
}
arbisyarifudin commented 3 months ago

the problem is i think from this file: (dynamic-pages)/layout.tsx

import { DynamicLayoutProviders } from './DynamicLayoutProviders';
import { AppSupabaseClient } from '@/types';
import { createSupabaseServerComponentClient } from '@/supabase-clients/createSupabaseServerComponentClient';

// do not cache this layout
export const dynamic = 'force-dynamic';
export const fetchCache = 'only-no-store';
export const revalidate = 0;

async function fetchSession(supabaseClient: AppSupabaseClient) {
  // This is a server-side call, so it will not trigger a revalidation
  const {
    data: { session },
    error,
  } = await supabaseClient.auth.getSession();

  if (error) {
    throw error;
  }

  return session;
}

export const metadata = {
  icons: {
    icon: '/images/logo-black-main.ico',
  },
  title: 'Super Day',
  description: 'Super Day',
};

export default async function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const supabaseClient = createSupabaseServerComponentClient();
  const [session] = await Promise.all([fetchSession(supabaseClient)]);
  return (
    <DynamicLayoutProviders initialSession={session}>
      {children}
    </DynamicLayoutProviders>
  );
}
vednig commented 2 months ago

Hey @arbisyarifudin, did you solve the issue I am getting the same problem recently, I have tried lot of things but none seem to be working.

vednig commented 1 month ago

@imbhargav5 a little help here?

imbhargav5 commented 1 month ago

Hi πŸ‘‹ will look at it first thing tomorrow.

On Thu, 5 Sep 2024 at 12:36β€―AM, Ved Nig @.***> wrote:

@imbhargav5 https://github.com/imbhargav5 a little help here?

β€” Reply to this email directly, view it on GitHub https://github.com/imbhargav5/nextbase-nextjs-supabase-starter/issues/33#issuecomment-2329781709, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWM6RD37V5CEW4J23DDCP3ZU5K4TAVCNFSM6AAAAABLB26CECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRZG44DCNZQHE . You are receiving this because you were mentioned.Message ID: @.*** com>

vednig commented 1 month ago

Any update, are you able to reproduce this?

imbhargav5 commented 1 month ago

Hi @vednig @arbisyarifudin I have actually been doing a complete rewrite the past few days. Sorry it took a bit longer, but I removed a few outdated patterns and this new code should fare a lot better.

vednig commented 1 month ago

That's great πŸŽ‰ , will you be using @supabase/ssr in it? And is there any expected timeline for updates?

vednig commented 1 month ago

I have an app in production, facing this error and I can find a solution to this problem, other than rebuilding it from scratch.

imbhargav5 commented 1 month ago

Yes . Already using supabase ssr. But it’s a bit inconsistent now. In about 1-2 weeks everything will be crisp.

On Sun, 8 Sep 2024 at 5:46β€―PM, Ved Nig @.***> wrote:

I have an app in production, facing this error and I can find a solution to this problem, other than rebuilding it from scratch.

β€” Reply to this email directly, view it on GitHub https://github.com/imbhargav5/nextbase-nextjs-supabase-starter/issues/33#issuecomment-2336663889, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWM6RBJ4T5ICSEI4ZY7LJLZVQ5YVAVCNFSM6AAAAABLB26CECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZWGY3DGOBYHE . You are receiving this because you were mentioned.Message ID: @.*** com>