-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server side authentication with cookies #60
Comments
Update: I ended up copying the HOC in this repo, but passing in the |
Hey @jimwheaton - glad you got that sorted. I'll make sure to update the lib to support this. |
Hi all, Are there any updates? |
I've got this exact use case as well. But, I'm not sure I totally follow how patching next-apollo to pass the context into @jimwheaton Any chance you have a snippet of what this looks like downstream of the changes you made to the HoC (and possibly what those changes look like in case I misunderstand)? ie. how you actually get the cookies out of the request/context and pass them along in your apollo client SSR requests? |
@alanctkc |
Let me fix it :) |
I just ran into a bit of strife trying to get this working as well. The documentation on the homepage (https://github.com/adamsoffer/next-apollo#documentation) implies that |
Does this still not work @adamsoffer? Seems like the docs or the software is broken. Maybe just put BROKEN - UNSUPPORTED on the readme? That way people don't waste their time with this package. I can make that PR if you like! |
@mikeruddy I just published |
I store an authentication token (JWT) in a cookie. I'm trying to access this server side by creating an
AuthLink
that I compose withHttpLink
, which is then passed to thewithData
HOC. The problem is that in myAuthLink
component, I don't seem to have access to the request so that I can set cookies so that the graphql request made ingetDataFromTree
is properly authenticated.I've looked at other approaches that are similar to
next-apollo
and they all pass in thectx
fromgetInitialProps
into the function that initializes theApolloClient
. For example:When using the
withData
HOC, it doesn't appear that the request context is made available to the ApolloClient init function, so I'm unable to access and set the cookies in the server side graphql request:I feel like I'm missing something obvious. How do I make an authenticated server side graphql request with
next-apollo
? Is there a way to get the current request so that I can get the cookies server side?The text was updated successfully, but these errors were encountered: