Skip to content
This repository has been archived by the owner on Dec 9, 2021. It is now read-only.

createGetServerSideAuth don't work #3

Closed
snk-js opened this issue Sep 28, 2020 · 3 comments
Closed

createGetServerSideAuth don't work #3

snk-js opened this issue Sep 28, 2020 · 3 comments

Comments

@snk-js
Copy link

snk-js commented Sep 28, 2020

Hi, I can't any way to get the cognito auth, to verify if I'm logged, there's any other way I can do this?

this way below don't work to me, always bring null on auth

export const getServerSideProps = async (context) => {
  const auth = await createGetServerSideAuth({ pems })(context.req)

  console.log('auth', auth) // result: null
};

@dferber90
Copy link
Owner

Did you read through this tutorial to see how to set things up?

@snk-js
Copy link
Author

snk-js commented Sep 28, 2020

Did you read through this tutorial to see how to set things up?

Yep, I made it work the login, but I can't hang a way to know If I'm already logged in. And that "createGetServerSideAuth" don't bring the authkeys, I tested pems, and context.req, It was suppose to work didn't?

[EDIT]: my getServerSideProps maybe not working. getInitialProps works, but don't know exactly why getServerSideProps can't pass data props to my component.

@dferber90
Copy link
Owner

It's unlikely that this is an issue of aws-cognito-next itself as this part works in the demo. Make sure you're on the latest Next.js version as getServerSideProps was introduced recently.

It's also better to call export const getServerSideAuth = createGetServerSideAuth({ pems }) once, and reuse the generated function as shown in the tutorial.

I'll close this issue for now as there are no concrete steps to reproduce it and it doesn't seem like this package is at fault.

Since I created this package, Amplify has added official support for server-side rendering, so you might want to look into using Amplify directly: aws-amplify/amplify-js#5435 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants