adamsoffer / next-apollo

React higher-order component for integrating Apollo Client with Next.js
MIT License
482 stars 64 forks source link

Can not set server-side authentication headers #72

Open monokrome opened 4 years ago

monokrome commented 4 years ago

The following comment suggests that this is possible, but I've spent the better part of the last 3 hours trying every trick in the book and can't find any solutions. Is this supported? We can't monkey patch it since it's not exported, but that seems excessive anyway. What is the expected use-case that this comment refers to?

https://github.com/adamsoffer/next-apollo/blob/master/src/withApollo.js#L181-L182

Thanks a bunch =^.^=

monokrome commented 4 years ago

Thoughts? @adamsoffer

adamsoffer commented 4 years ago

hm that's odd. Sorry for the trouble. I'm not sure why the headers wouldn't be getting set. I'll look into this. Out of curiosity, if you use the with-apollo example in the next.js repo do the headers get set? This lib essentially just packages up and creates an abstraction based on that example.

shoaibsharif commented 4 years ago

I also had the same issue. I used with-apollo in the next.js repo and I have noticed the same issue too. On client-side it works perfectly. if you want a demo you can visit https://dev.techdiary.dev. if you login and then go to Menu>dashboard and refresh the page it pass the headers every time but. But if you go to / page (which is server side) the cookie doesn't pass, hence it shows me as not logged in any more. If you find any solution please le me know. FYI, cookie sets everytime I log in but if I refresh the page it doesn't send cookie anymore but on the client side, it sends cookie everytime.