ryanwalters / amplify-auth-next-storage

Isomorphic cookie storage for Next.js apps using @aws-amplify/auth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Apollo Client SSR when AppSync requires the JWT for auth

tombuckley91 opened this issue · comments

Firstly, thank you for putting this together, I was pretty shocked to see someone had literally built the exact thing I had in mind, so thank you for that.

I'm currently dealing with a problem whereby my apollo client requires an authorisation header to be able to communicate with my AppSync GQL layer. Currently my "withApollo" client provider is a HOC that wraps _app, from what I can gauge this means that it won't have access to the NextJS ctx object. I just wanted to get your opinion on a solution, I'm thinking I might be able to instantiate the Apollo Client in the recently introduced 'getServerSideProps' so that it has access to ctx but I'm not sure. Clearly you too have been somewhat close to this problem and I just wanted to get your opinion on it.

Anyway, thanks for your time @ryanwalters.

getServerSideProps is not the place, the created client can not be passed as serialised JSON (of course...)

I will do a write up how I got this working, @tombuckley91 [TODO] - Update #5 with how you got SSR with auth working.