#when i build and this got error how to solve this?

22 messages ยท Page 1 of 1 (latest)

pearl berryBOT
#

๐Ÿ”Ž This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

๐Ÿ•ต๏ธ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

โœ… You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

runic basin
#

Can you show the code where you re using cookies()? Also which next.js ver are u using?

elfin carbon
#
import { EnteredChatList, RecommendedChatList } from '@/types/types';
import { cookies } from 'next/headers';

const options = {
  credentials: 'include',
  headers: { Cookie: `ACCESS=${cookies().get('ACCESS')?.value}` },
} as const;

export async function fetchEnteredChatList(): Promise<EnteredChatList[]> {
  const url = `${process.env.SERVER_API_URL}/api/chatroom/participated`;
  const response = await fetch(url, options);
  return response.json();
}

@runic basin i m using 13.5.2 version

runic basin
#

Can you try upgrading to v14? (Or v13.5.6)

elfin carbon
#

yes sir

#

@runic basin same got error

mild vale
#

can you please move options within fetchEnteredChatList block?

#

and try ๐Ÿ™‚

#

I believe you can't access it from the global scope, it should be done inside a component or a route

elfin carbon
#

wow it works

#

but i have 1 question

#

Do I have to put all options in the function repeatedly?
@mild vale

#

If there are several functions like this..
fetchEnteredChatList1() ~ fetchEnteredChatList100()...

mild vale
#

I mean, you can reuse that piece of logic, but as I said cookies() must be called within component or route in order to work properly.
Maybe try something like

const options = () => ({
credentials: 'include',
  headers: { Cookie: `ACCESS=${cookies().get('ACCESS')?.value}` }
} as const);

function yourFunction() {
  options();
}

I'm not sure right now, but yeah, you should be able to reuse that logic

mild vale
#

just mark post as resolved/answered

elfin carbon
#

ok

mild vale
#

right click => apps => mark as resolved

#

๐Ÿ™‚

elfin carbon
#

sry i m new...
finding mark button rn...

mild vale