Open kaloraat opened 4 years ago
@kaloraat You can't use React context here, as that's not even a component, and it gets created outside one, what you could do is import firebase and use one of its APIs to get the token without using a React hook.
Keep in mind that if the token is not available in the server (cookies is the only way to make it available for the server), then you'll only be able to add authentication for client-side rendering
@kaloraat You can't use React context here, as that's not even a component, and it gets created outside one, what you could do is import firebase and use one of its APIs to get the token without using a React hook.
Keep in mind that if the token is not available in the server (cookies is the only way to make it available for the server), then you'll only be able to add authentication for client-side rendering
Ya I thought so, thanks for your response
Hi The
withApollo
HOC example works perfectly but I need to sendauthtoken
inheaders
, which is coming from react context (I am using firebase authtoken, not localStorage or cookie) which is available in my context. Can you please help how I can access context in thiswithApollo
HOC example?Later I will need to add more configuration such as webSocket link for subscription etc
This is my code, Only thing I have added is import
Context
so that I can access token from context and send in headers. Thx