Closed jrwpatterson closed 9 months ago
Hello, @jrwpatterson π and sorry to hear you're running into these errors. To make sure this isn't an easy fix first, can you first try deleting your node_modules
folder, then deleting your package-lock.json
, and then reinstalling dependencies with npm i
helps resolve the issue?
If it doesn't, can you check to see if there are multiple versions of the aws-crypto/sha256-js
or smithy/util-utf8
dependencies? You should be able to run npm ls @aws-crypto/sha256-js
and npm ls @smithy/util-utf8
and see if you get more than 1 output.
I have started seeing the same issue recently. when using the latest @aws-amplify/adapter-nextjs
npm package that pulls in various aws
packages.
./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
Deleting the node_modules
folder, and package-lock.json
does not resolve the issue.
npm ls @smithy/util-utf8
output
βββ¬ @aws-amplify/adapter-nextjs@1.0.13
βββ¬ aws-amplify@6.0.13
βββ¬ @aws-amplify/analytics@7.0.13
β βββ¬ @aws-sdk/client-firehose@3.398.0
β β βββ¬ @aws-sdk/client-sts@3.398.0
β β β βββ @smithy/util-utf8@2.0.0 deduped
β β βββ¬ @aws-sdk/credential-provider-node@3.398.0
β β β βββ¬ @aws-sdk/credential-provider-sso@3.398.0
β β β βββ¬ @aws-sdk/client-sso@3.398.0
β β β β βββ @smithy/util-utf8@2.0.0 deduped
β β β βββ¬ @aws-sdk/token-providers@3.398.0
β β β βββ @smithy/util-utf8@2.0.0 deduped
β β βββ¬ @aws-sdk/middleware-signing@3.398.0
β β β βββ¬ @smithy/signature-v4@2.1.1
β β β βββ @smithy/util-utf8@2.1.1
β β βββ¬ @smithy/hash-node@2.1.1
β β β βββ @smithy/util-utf8@2.1.1
β β βββ¬ @smithy/smithy-client@2.3.1
β β β βββ¬ @smithy/util-stream@2.1.1
β β β βββ @smithy/util-utf8@2.1.1
β β βββ @smithy/util-utf8@2.0.0 deduped
β βββ¬ @aws-sdk/client-kinesis@3.398.0
β β βββ @smithy/util-utf8@2.0.0 deduped
β βββ¬ @aws-sdk/client-personalize-events@3.398.0
β β βββ @smithy/util-utf8@2.0.0 deduped
β βββ @smithy/util-utf8@2.0.0
βββ¬ @aws-amplify/core@6.0.13
β βββ¬ @aws-crypto/sha256-js@5.2.0
β βββ¬ @aws-crypto/util@5.2.0
β βββ @smithy/util-utf8@2.0.0 deduped
βββ¬ @aws-amplify/storage@6.0.13
βββ¬ @smithy/md5-js@2.0.7
βββ @smithy/util-utf8@2.0.0 deduped
npm ls @aws-crypto/sha256-js
output:
βββ¬ @aws-amplify/adapter-nextjs@1.0.13
βββ¬ aws-amplify@6.0.13
βββ¬ @aws-amplify/analytics@7.0.13
β βββ¬ @aws-sdk/client-firehose@3.398.0
β β βββ¬ @aws-crypto/sha256-browser@3.0.0
β β β βββ @aws-crypto/sha256-js@3.0.0
β β βββ @aws-crypto/sha256-js@3.0.0
β β βββ¬ @aws-sdk/client-sts@3.398.0
β β β βββ @aws-crypto/sha256-js@3.0.0
β β βββ¬ @aws-sdk/credential-provider-node@3.398.0
β β βββ¬ @aws-sdk/credential-provider-sso@3.398.0
β β βββ¬ @aws-sdk/client-sso@3.398.0
β β β βββ @aws-crypto/sha256-js@3.0.0
β β βββ¬ @aws-sdk/token-providers@3.398.0
β β βββ @aws-crypto/sha256-js@3.0.0
β βββ¬ @aws-sdk/client-kinesis@3.398.0
β β βββ @aws-crypto/sha256-js@3.0.0
β βββ¬ @aws-sdk/client-personalize-events@3.398.0
β βββ @aws-crypto/sha256-js@3.0.0
βββ¬ @aws-amplify/core@6.0.13
βββ @aws-crypto/sha256-js@5.2.0
Hi @grasdal looking at the output of npm ls @smithy/util-utf8
it's odd that aws-amplify@6.0.13
is a leaf on the tree of @aws-amplify/adapter-nextjs@1.0.13
. aws-amplify
is a peer dependency, so it should be located right under your project.
Could you share the content of the dependencies
section in your package.json
?
@HuiSF
I normally would also would have aws-amplify
in my dependencies
, however, for the above post I reduced it to only @aws-amplify/adapter-nextjs
from Amplify to show that the build issue persisted even with a minimum example of letting the @aws-amplify/adapter-nextjs
package pull in amplify for me.
This is how the full dependencies
looks when both aws-amplify
and @aws-amplify/adapter-nextjs
included
Installing with
npm i aws-amplify @aws-amplify/adapter-nextjs
results in
"dependencies": {
"@aws-amplify/adapter-nextjs": "^1.0.13",
"@datadog/browser-rum": "^5.8.0",
"@headlessui/react": "^1.7.18",
"@headlessui/tailwindcss": "^0.2.0",
"@heroicons/react": "^2.1.1",
"@hookform/resolvers": "^3.3.4",
"@next/bundle-analyzer": "^14.1.0",
"@tanstack/react-query": "^5.17.19",
"@tanstack/react-query-devtools": "^5.17.21",
"aws-amplify": "^6.0.13",
"base64url": "^3.0.1",
"bitmovin-player": "^8.149.0",
"bitmovin-player-ui": "^3.53.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"date-fns": "^3.3.1",
"jsonwebtoken": "^9.0.2",
"moment": "^2.30.1",
"next": "^14.1.0",
"next-international": "^1.2.3",
"next-themes": "^0.2.1",
"nextjs13-progress": "^1.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.12",
"react-hook-form": "^7.49.3",
"react-multi-carousel": "^2.8.4",
"sharp": "^0.33.2",
"ua-parser-js": "^1.0.37",
"use-debounce": "^10.0.0",
"uuid": "^9.0.1",
"zod": "^3.22.4"
},
"devDependencies": {
"@tanstack/eslint-plugin-query": "^5.17.20",
"@types/jsonwebtoken": "^9.0.5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/ua-parser-js": "^0.7.39",
"@types/uuid": "^9.0.7",
"autoprefixer": "^10.4.17",
"eslint": "^8",
"eslint-config-next": "14.1.0",
"eslint-plugin-validate-filename": "^0.0.4",
"postcss": "^8",
"prettier": "^3.2.4",
"prettier-plugin-tailwindcss": "^0.5.11",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
npm ls @smithy/util-utf8
output
βββ¬ aws-amplify@6.0.13
βββ¬ @aws-amplify/analytics@7.0.13
β βββ¬ @aws-sdk/client-firehose@3.398.0
β β βββ¬ @aws-sdk/client-sts@3.398.0
β β β βββ @smithy/util-utf8@2.0.0 deduped
β β βββ¬ @aws-sdk/credential-provider-node@3.398.0
β β β βββ¬ @aws-sdk/credential-provider-sso@3.398.0
β β β βββ¬ @aws-sdk/client-sso@3.398.0
β β β β βββ @smithy/util-utf8@2.0.0 deduped
β β β βββ¬ @aws-sdk/token-providers@3.398.0
β β β βββ @smithy/util-utf8@2.0.0 deduped
β β βββ¬ @aws-sdk/middleware-signing@3.398.0
β β β βββ¬ @smithy/signature-v4@2.1.1
β β β βββ @smithy/util-utf8@2.1.1
β β βββ¬ @smithy/hash-node@2.1.1
β β β βββ @smithy/util-utf8@2.1.1
β β βββ¬ @smithy/smithy-client@2.3.1
β β β βββ¬ @smithy/util-stream@2.1.1
β β β βββ @smithy/util-utf8@2.1.1
β β βββ @smithy/util-utf8@2.0.0 deduped
β βββ¬ @aws-sdk/client-kinesis@3.398.0
β β βββ @smithy/util-utf8@2.0.0 deduped
β βββ¬ @aws-sdk/client-personalize-events@3.398.0
β β βββ @smithy/util-utf8@2.0.0 deduped
β βββ @smithy/util-utf8@2.0.0
βββ¬ @aws-amplify/core@6.0.13
β βββ¬ @aws-crypto/sha256-js@5.2.0
β βββ¬ @aws-crypto/util@5.2.0
β βββ @smithy/util-utf8@2.0.0 deduped
βββ¬ @aws-amplify/storage@6.0.13
βββ¬ @smithy/md5-js@2.0.7
βββ @smithy/util-utf8@2.0.0 deduped
npm ls @aws-crypto/sha256-js
output
βββ¬ aws-amplify@6.0.13
βββ¬ @aws-amplify/analytics@7.0.13
β βββ¬ @aws-sdk/client-firehose@3.398.0
β β βββ¬ @aws-crypto/sha256-browser@3.0.0
β β β βββ @aws-crypto/sha256-js@3.0.0
β β βββ @aws-crypto/sha256-js@3.0.0
β β βββ¬ @aws-sdk/client-sts@3.398.0
β β β βββ @aws-crypto/sha256-js@3.0.0
β β βββ¬ @aws-sdk/credential-provider-node@3.398.0
β β βββ¬ @aws-sdk/credential-provider-sso@3.398.0
β β βββ¬ @aws-sdk/client-sso@3.398.0
β β β βββ @aws-crypto/sha256-js@3.0.0
β β βββ¬ @aws-sdk/token-providers@3.398.0
β β βββ @aws-crypto/sha256-js@3.0.0
β βββ¬ @aws-sdk/client-kinesis@3.398.0
β β βββ @aws-crypto/sha256-js@3.0.0
β βββ¬ @aws-sdk/client-personalize-events@3.398.0
β βββ @aws-crypto/sha256-js@3.0.0
βββ¬ @aws-amplify/core@6.0.13
βββ @aws-crypto/sha256-js@5.2.0
When troubleshooting further the cryptic error in our project seems related to a child component of a client component importing a components tagged with 'use server'
that contain amplify server code such as createServerRunner
.
Specifically we had a package that contained mixed client and server named exports in its index.tsx
where the belowuseServerAuthentication
was exported.
Old code for a 'useServerAuthentication.tsx' (react hook pattern on server side) π€·
'use server';
import { createServerRunner } from '@aws-amplify/adapter-nextjs';
import { getCurrentUser as ampGetCurrentUser, fetchAuthSession } from 'aws-amplify/auth/server';
import { cookies } from 'next/headers';
import { config } from '../utils/AmplifyConfiguration';
const useServerAuthentication = async () => {
const { runWithAmplifyServerContext } = createServerRunner({ config });
const getCurrentUser = async () => {
try {
const { username, userId, signInDetails } = await runWithAmplifyServerContext({
nextServerContext: { cookies },
operation: (contextSpec) => ampGetCurrentUser(contextSpec),
});
return { username, userId, signInDetails };
} catch {
// user is not logged in
return undefined;
}
};
...
Anytime this ends up somewhere in the child tree of another 'use client'
component we get the build error
> next build
β² Next.js 14.1.0
- Environments: .env
Creating an optimized production build ...
Failed to compile.
./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
In order to resolve it the line const { runWithAmplifyServerContext } = createServerRunner({ config });
was simply moved into a server-utils.tsx
file (following patterns from https://aws.amazon.com/blogs/mobile/amplify-javascript-v6/ )
import { createServerRunner } from '@aws-amplify/adapter-nextjs';
import { generateServerClientUsingCookies } from '@aws-amplify/adapter-nextjs/api';
import { cookies } from 'next/headers';
import { config } from './AmplifyConfiguration';
export const serverClient = generateServerClientUsingCookies({
config,
cookies,
});
export const { runWithAmplifyServerContext } = createServerRunner({ config });
So now useServerAuthentication.tsx
becomes
'use server';
import { getCurrentUser as ampGetCurrentUser, fetchAuthSession } from 'aws-amplify/auth/server';
import { cookies } from 'next/headers';
import { runWithAmplifyServerContext } from '../utils/server-utils';
const useServerAuthentication = async () => {
const getCurrentUser = async () => {
try {
const { username, userId, signInDetails } = await runWithAmplifyServerContext({
nextServerContext: { cookies },
operation: (contextSpec) => ampGetCurrentUser(contextSpec),
});
return { username, userId, signInDetails };
} catch {
// user is not logged in
return undefined;
}
};
...
and now the build error is gone :)
Thanks for the follow-up. @grasdal So it sounds like when mix-matched client and service-specific code, the underlying bundler of Next.js cannot resolve the correct module to build the bundles, respectively, for client and server. That makes sense. Glad that you were able to locate the cause.
Is there anything else we can assist you here?
I am in the same situation with mixed server and client components in a form action as @grasdal however I'm following the recommended practice of exporting the server context runner from utils (e.g. import { runWithAmplifyServerContext } from 'app/lib/utils'
) and still seeing the error.
Hey @gavacq everything under app
is a part of the route following Next.js's spec. And as Next.js evaluates it as server side code by default, that may cause issues.
Can you try to move the utils out of the app
directory see if it makes any difference?
Hi @HuiSF , I moved utils out of the app directory and the error persists:
./lib/utils
βββ amplifyServerUtils.ts
./app/user/
βββ actions.ts <-- import { runWithAmplifyServerContext } from 'lib/utils'
I understand your troubleshooting approach, but I want to highlight that NextJS does support safe colocation of project files in the app
directory.
Hi @gavacq thanks for pointing that out.
I did some testing but I couldn't reproduce this error. Here's my set up for testing:
src
βΏapp
βΏtest-page
βΏactions
βΏserverAction.tsx (exports serverAction)
βΏpage.tsx
βΏ<ClientForm />
βΏcomponents
βΏClientForm.tsx ('use client', imports `serverAction`)
βΏ<form action={serverAction}><input type='submit'/></form>
βΏamplifyUtils.ts
βΏrunWithAmplifyServerContext
The serverAction.tsx
contains
"use server";
import { cookies } from "next/headers";
import { runWithAmplifyServerContext } from "@/amplifyUtils";
import { fetchAuthSession } from "aws-amplify/auth/server";
export const submitForm = async (formData: FormData) => {
const session = await runWithAmplifyServerContext({
nextServerContext: { cookies },
operation: (contextSpec) => fetchAuthSession(contextSpec),
});
console.log("π ~ SubmitForm ~ session:", session);
};
npx next build
completed without errorsserverAction
works as expectedCould you try to create a minimum app that can reproduce this issue and share with us?
I want to help with this but I've already transitioned off AmplifyUI and Cognito for unrelated reasons and I doubt I'll have time to reproduce this. I really appreciate your time debugging this, thank you.
@gavacq we'll close this issue then for now, but let us know if you get time to reproduce this so we can dig deeper. Thanks!
Getting the same issue, tried switching to require instead of import of @aws-amplify/adapter-nextjs library as suggested here:
https://www.sanity.media/p/65a2421194f7a8782500f775-how-i-fixed-aws-crypto-build-error
The build error is gone but now I am getting this error while calling the fetchAuthSession method
Attempted to get the Amplify Server Context that may have been destroyed.
Please suggest if there is any solution
Hi @bhaveshabuild Could you provide a minimal sample repo that can reproduce this error you saw so I can do some digging?
@HuiSF Hello, I am facing the same issue. Could you please share the specific code you mentioned in https://github.com/aws-amplify/amplify-js/issues/12856#issuecomment-1939594022 where you confirmed the error does not occur? I would like to verify it by myself.
For your reference, here is what have tried:
bunx create-next-app
bun run dev
β It works β
β my-app git:(main) β bun run dev
$ next dev
β² Next.js 14.1.1
- Local: http://localhost:3000
β Ready in 1451ms
β Compiling / ...
β Compiled / in 1748ms (514 modules)
β Compiled in 110ms (244 modules)
β Compiled /favicon.ico in 100ms (521 modules)
β Compiling /test-page ...
β Compiled /test-page in 649ms (930 modules)
π ~ SubmitForm ~ session: {
tokens: {
accessToken: { toString: [Function: toString], payload: [Object] },
idToken: { toString: [Function: toString], payload: [Object] },
signInDetails: undefined
},
credentials: undefined,
identityId: undefined,
userSub: '4afecbb7-c279-4bc5-acbf-3adde2d87f3f'
}
bun run build
β error occurs β
β my-app git:(main) β bun run build
$ next build
β² Next.js 14.1.1
Creating an optimized production build ...
Failed to compile.
../node_modules/@aws-crypto/sha256-js/build/module/index.js + 13 modules Cannot get final name for export 'fromUtf8' of ../node_modules/@aws-crypto/util/node_modules/@smithy/util-utf8/dist-es/index.js
Build failed because of webpack errors error: script "build" exited with code 1
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@aws-amplify/adapter-nextjs": "^1.0.18",
"next": "14.1.1",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"eslint": "^8",
"eslint-config-next": "14.1.1"
}
}
β amplify-test tree my-app/app
my-app/app
βββ components
β βββ ClientForm.tsx
βββ favicon.ico
βββ globals.css
βββ layout.tsx
βββ page.tsx
βββ test-page
βββ actions
β βββ serverAction.tsx
βββ page.tsx
and there is my-app/amplifyUtils.ts
.
my-app/app/test-page/page.tsx
import ClientForm from "../components/ClientForm";
export default function Page() {
return <ClientForm />;
}
my-app/app/components/ClientForm.tsx
"use client";
import { submitForm } from "../test-page/actions/serverAction";
export default function ClientForm() {
return (
<div>
<h1>Test Page</h1>
<button
onClick={(e) => {
e.preventDefault();
submitForm(new FormData());
}}
>
Submit
</button>
</div>
);
}
my-app/app/test-page/actions/serverAction.tsx
"use server";
import { cookies } from "next/headers";
import { fetchAuthSession } from "aws-amplify/auth/server";
import { runWithAmplifyServerContext } from "../../../amplifyUtils";
export const submitForm = async (formData: FormData) => {
const session = await runWithAmplifyServerContext({
nextServerContext: { cookies },
operation: (contextSpec) => fetchAuthSession(contextSpec),
});
console.log("π ~ SubmitForm ~ session:", session);
};
my-app/amplifyUtils.ts
import { createServerRunner } from "@aws-amplify/adapter-nextjs";
export const amplifyConfig = {
// config info here...
};
export const { runWithAmplifyServerContext } = createServerRunner({
config: amplifyConfig,
});
I've solved error in my codebase.
I just changed how to pass Server Actions to Client Component from importing directly to passing via props.
It's unclear how this relates to the advice previously posted by @grasdal, but regardless of where const { runWithAmplifyServerContext } = createServerRunner({ config });
is placed, it might be problematic import Server Actions that use runWithAmplifyServerContext
(either directly or indirectly) within Client Components.
app/lib/amplify-server.ts
(Amplify Codes)
import { amplifyConfig } from "@/lib/amplify-config";
import { createServerRunner } from "@aws-amplify/adapter-nextjs";
import { fetchAuthSession } from "aws-amplify/auth/server";
import { cookies } from "next/headers";
export const { runWithAmplifyServerContext } = createServerRunner({
config: amplifyConfig,
});
export const getCurrentSessionTokens = async () => {
const { tokens } = await runWithAmplifyServerContext({
nextServerContext: { cookies },
operation: (contextSpec) => fetchAuthSession(contextSpec),
});
if (!tokens) {
throw new Error("No tokens found in the session.");
}
return tokens;
};
app/lib/actions.ts
οΌServer Actions)
"use server";
import { getCurrentSessionTokens } from "@/lib/amplify-server";
// some other imports
export async function updateSomething(prevState: State, formData: FormData) {
// ...
const tokens = await getCurrentSessionTokens();
const response = await fetch(`/api/endpoint`, {
method: "PUT",
headers: {
Authorization: `Bearer ${tokens.idToken}`,
"Content-Type": "application/json",
},
body: // ...
cache: "no-store",
});
// ...
};
app/profile/edit/components/edit-form.tsx
οΌClient ComponentοΌ
"use client";
// === This might be problem ===
import { updateProfile } from "@/lib/actions";
import { useFormState } from "react-dom";
function Form({
user,
}: {
user: User;
}) {
const [state, dispatch] = useFormState(updateProfile, {
message: "",
errors: {},
});
return (
<form action={dispatch} className="space-y-5">
{/* ... */}
</form>
);
}
export { Form };
app/profile/edit/page.tsx
οΌPageοΌ
import { getCurrentUserFromAPI } from "@/lib/data";
import { Form } from "@/profile/edit/components/edit-form";
export default async function Page() {
const user = await getCurrentUserFromAPI();
return (
<main className="pt-10 text-center">
<section className="space-y-10">
<h1 className="text-3xl">Title</h1>
<Form user={user} />
</section>
</main>
);
}
app/lib/amplify-server.ts
has no change.
I just pass Server Actions by props to Client Component.
app/profile/edit/page.tsx
οΌPageοΌ
+ import { updateProfile } from "@/lib/actions";
import { getCurrentUserFromAPI } from "@/lib/data";
import { Form } from "@/profile/edit/components/edit-form";
export default async function Page() {
const user = await getCurrentUserFromAPI();
return (
<main className="pt-10 text-center">
<section className="space-y-10">
<h1 className="text-3xl">Title</h1>
- <Form user={user} />
+ <Form user={user} updateProfile={updateProfile} />
</section>
</main>
);
}
app/profile/edit/components/edit-form.tsx
οΌClient ComponentοΌ
"use client";
- import { updateProfile } from "@/lib/actions";
+ import { IUpdateProfile } from "@/lib/actions";
import { useFormState } from "react-dom";
function Form({
user,
+ updateProfile,
}: {
user: User;
+ updateProfile: IUpdateProfile;
}) {
const [state, dispatch] = useFormState(updateProfile, {
message: "",
errors: {},
});
return (
<form action={dispatch} className="space-y-5">
{/* ... */}
</form>
);
}
export { Form };
I've found a solution here worked for me: https://github.com/vercel/next.js/issues/59344#issuecomment-1846128759
adding the package into next.config.js :
experimental: { serverComponentsExternalPackages: [ '@aws-amplify/adapter-nextjs', 'aws-amplify' ] }
@harryhaibojiang It worked for me as well! Thank you for sharing π
Oh my, my apologies missing all the conversation here. Thanks @harryhaibojiang and @sasumasa for digging into this further.
Your workaround fully makes sense to me @sasumasa, that creates a clear boundary between the server and client bundles.
I will evaluate the workaround posted in the linked Next.js issue, and watch this experimental feature status, might be worth to add it into a troubleshooting section in the documentation.
@HuiSF Thanks for reply.
Your workaround fully makes sense to me @sasumasa, that creates a clear boundary between the server and client bundles.
Yes, it seem that creates clear boundary, but Server Actions are executed on the server regardless of whether they are passed from Server Component or imported in Client Component.
Wouldn't this mean that both are included in the Server Bundle? This point is what I don't understand yet.
Hi all, thanks for continually providing information about this issue.
I was able to reproduce this build error when I was attempting import a server action implementation into a client side component that uses useFormState
hook following Next.js documentation: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#server-side-validation-and-error-handling
Looking at the dependencies tree, @aws-crypto/sha256-js
is used by the underlying aws-sdk that's consumed by the analytics package. Even though it's not used, it presents on the module evaluation paths hence the error.
While @harryhaibojiang 's workaround is viable, I found that with listing entire aws-amplify
as a serverComponentsExternalPackages
, runWithAmplifyServerContext
may fails at some occasions in the context of the Next.js page router, to avoid this, please list only the problematic dependencies.
E.g.
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ['@aws-crypto'],
},
};
export default nextConfig;
I will add this information into Amplify public documentation.
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
Other
Environment information
Describe the bug
When running this code on the server
When I run the nextjs build script I get the following error
Expected behavior
The application should build
Reproduction steps
add this to a server side function
run next build
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response