Next.js Discord

Discord Forum

I don't know why server side rendering not working on vercel deployment

Unanswered
Thrianta posted this in #help-forum
Open in Discord
ThriantaOP
I don't know why server side rendering not working on vercel deployment but same code working in my localhost. After investigate the log I found cookie are not sending to my backend and don't know why? I must be sent sessionid. am I doing any mistake? The same code working on localhost:3000 and also sending the cookie

async function getData() {
  const cookieStore = cookies();
  const session_id = cookieStore.get("sessionid");
  const csrftoken = cookieStore.get("csrftoken");
  
  try {
   
    const userisAdmin = await fetch(`${domain_name}/user_staff`, {
      method: 'get',
      headers: {
        'Content-Type': 'application/json',
        'Cookie': `sessionid=${session_id.value}; csrftoken=${csrftoken.value}`,
      },
      
   });

     const result = await userisAdmin.json()   
  
    return {
      userprofile: result ,
    };
  } catch (error) {
    console.error('Error:', error);
    return {
      userprofile: null,
    };
  }
}

export default async function Adminpage() {
  const user = await getData();
  console.log(user)

  return (
    <>
        {user?.userprofile?.extra_data?.name ?(<>
          <Admin UserName={user.userprofile.extra_data.name}  />
        </>):(<>... others code

here is log

Error: TypeError: Cannot read properties of undefined (reading 'value')
    at getData (/var/task/fontendfb/.next/server/app/admin/page.js:1:21272)
    at Adminpage (/var/task/fontendfb/.next/server/app/admin/page.js:1:21445)
    at /var/task/fontendfb/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:109:21573
    at /var/task/fontendfb/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:109:21702
 

0 Replies