This build error occurs when you want to use next/header from a server component that uses a client component in one of its parent components.
In the case that there is a client component in one of its parent components, if caller of api client function is server component, It worked fine with dev environment (npm run dev). However, build(npm run build) error happened.
According to my understanding, if we use even one client component in one of its parent components, we cannot use cookie function from next/header.
./node_modules/@aws-crypto/sha256-js/build/module/index.js + 12 modules
Cannot get final name for export 'fromUtf8' of ./node_modules/@smithy/util-utf8/dist-es/index.js
So, I am going to make a separate ApiClient for both Client Component and Server Component.
Criteria
[x] Create ApiClient method for client component, including getToken method
I have also tried and gained experience: client cookies are available in client components, and server cookies are available in server components. These different cookies are not accessible to each other. It looks like this is another flaw in NextJS
Description
This build error occurs when you want to use
next/header
from a server component that uses a client component in one of its parent components.In the case that there is a client component in one of its parent components, if caller of api client function is server component, It worked fine with dev environment (
npm run dev
). However, build(npm run build
) error happened.According to my understanding, if we use even one client component in one of its parent components, we cannot use cookie function from
next/header
.So, I am going to make a separate ApiClient for both Client Component and Server Component.
Criteria
getToken
methodNotes
Similar problem