Skip to content
Discussion options

You must be logged in to vote

Okay, I seem to be able to solve this issue by myself. What I noticed by trial and error is that if I remove my serverSideTranslations and use getServerSideProps instead of getStaticProps on my desired page and use the await getSession(), things seem to be working. So, this is how it looks:

export const getServerSideProps = async (ctx: GetServerSidePropsContext) => ({
  props: {
    ...(await serverSideTranslations(ctx.locale, [
      'header',
      'common',
      'itemcard',
      'footer',
    ])),
    session: await getSession(ctx),
  },
});

I am using next-i18next as my localization package. The problem seems to be with the getStaticProps, as the page gets built before the session …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by GvidasP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
question Ask how to do something or how something works
1 participant
Converted from issue

This discussion was converted from issue #4173 on March 15, 2022 04:09.