nextbase-nextjs-supabase-starter icon indicating copy to clipboard operation
nextbase-nextjs-supabase-starter copied to clipboard

Deployed to Vercel with 404 Not Found result

Open arbisyarifudin opened this issue 1 year ago β€’ 10 comments

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 avatar Jul 18 '24 04:07 arbisyarifudin

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 avatar Jul 18 '24 05:07 arbisyarifudin

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>
  );
}

arbisyarifudin avatar Jul 18 '24 05:07 arbisyarifudin

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 avatar Sep 03 '24 06:09 vednig

@imbhargav5 a little help here?

vednig avatar Sep 04 '24 19:09 vednig

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>

imbhargav5 avatar Sep 05 '24 02:09 imbhargav5

Any update, are you able to reproduce this?

vednig avatar Sep 06 '24 09:09 vednig

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.

imbhargav5 avatar Sep 06 '24 14:09 imbhargav5

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

vednig avatar Sep 08 '24 12:09 vednig

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

vednig avatar Sep 08 '24 12:09 vednig

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>

imbhargav5 avatar Sep 08 '24 12:09 imbhargav5