0

hi i am trying to hosting the dynamic web page. i use the getServerSideProps function to sign with google for everyone.

but when i hosting the web there is a error with getServerSideProps. how can i fix it??

here is the signIn code including the getServerSideProps:

import {getProviders, signIn as SignIntoProvider } from "next-auth/react";
import Header from "../../components/Header";
import Image from "next/future/image";
//Brower...
function signIn({providers}){
    return (
        <>
        <Header />

        <div className="flex flex-col items-center min-h-screen py-2 mt-56 text-center">
            <Image className="w-80" src="/img/스쿼드 로고.png" alt="" width={400} height={200}/>

            <p className="font-xs italic">
                SQUARD PROJECT - By EunSeo PARK  
            </p>
                <div className='mt-20'>
                    {Object.values(providers).map((provider) => (
                        <div key={provider.name}>
                            <button className="p-3 bg-blue-500 rounded-lg text-white" onClick={() => SignIntoProvider(provider.id, {callbackUrl: "/"})}>
                                Sign in with {provider.name}
                            </button>
                        </div>
                    ))}
                </div>
        </div>
    </>
    );
}

//Server side 
export async function getServerSideProps() {
    const providers = await getProviders();

    return {
        props: {
            providers,
        },
    };

}

export default signIn;

And here is the error code:

[WARNING]: Error occurred prerendering page "/auth/signin". Read more: https://nextjs.org/docs/messages/prerender-error
                                    Error: Error for page /auth/signin: pages with `getServerSideProps` can not be exported. See more info here: https://nextjs.org/docs/messages/gssp-export
                                    at /codebuild/output/src687705454/src/SNS-Community-Instagram/node_modules/next/dist/export/worker.js:218:27
                                    at async Span.traceAsyncFn (/codebuild/output/src687705454/src/SNS-Community-Instagram/node_modules/next/dist/trace/trace.js:79:20)
juliomalves
  • 42,130
  • 20
  • 150
  • 146
nuguri
  • 1
  • 1
  • Have you checked the error message and the link provided there (https://nextjs.org/docs/messages/gssp-export)? As it states, you're trying to statically export your app but `getServerSideProps` is not supported with `next export`. Also note that `next-auth` is not supported with `next export` as it requires API routes to work, which `next export` doesn't support. See https://nextjs.org/docs/advanced-features/static-html-export#unsupported-features. – juliomalves Oct 01 '22 at 14:30
  • Thank you for helping me! i read that links! so it means remove 'next export' in package.json and change getServerSideProps to getStaticProps?? (sorry.. i am the beginner :( please help me) – nuguri Oct 02 '22 at 04:43
  • Removing `next export` should be enough. – juliomalves Oct 02 '22 at 10:39

0 Answers0