I am trying to setup aws amplify on my next js app, with app directory to run on server side.
Here is my setup code:
import { Amplify } from "aws-amplify";
interface Props {
children: React.ReactNode;
}
const awsconfig = {
region: process.env.NEXT_PUBLIC_COGNITO_REGION,
userPoolId: process.env.NEXT_PUBLIC_COGNITO_USER_POOL_ID,
userPoolWebClientId: process.env.NEXT_PUBLIC_COGNITO_USER_POOL_WEB_CLIENT_ID,
};
Amplify.configure({ Auth: awsconfig, ssr: true });
export const AwsAmplifyProvider = ({ children }: Props) => {
return <>{children}</>;
};
I am always getting the error:
51:29.191 AuthError -
Error: Amplify has not been configured correctly.
Note: This only happens if I try to run it on the server, If I try to run the same config on the client side, using "use client", it works perfectly.
what could be the issue? What am i missing here? Thanks.