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
Missing the cookie header or object #84
Comments
Running into this issue as well. |
I returned to the version I was using the longest, |
With what bundler are you using this library? It seems like it is mistakingly thinking you are in a Node.js environment. |
I'm using Webpack with React and universal routing, which I think is the problem. Should I be using For the client side, I'm trying to write a helper module that will access cookies. This helper will be used in my React components. |
If you care about async server-rendering you should definitively use |
Currently having this issue when running tests as well. |
@Brantron when testing, you might want to mock your cookies and passing it to the |
@garythung @davidsonsns I've fixed this issue in v2.0.8. Can you confirm you no longer have this issue? |
Using 2.0.8 and getting error: Error: Missing the cookie header or object. Using universal-cookie with server side rendering and hot reload. I would comment out the code, refresh the page and it loads the page. I'll then uncomment the new Cookie() code and reload the page and it fully works after that... |
@andrefox333 this is because you are doing server-rendering but you are not providing the cookie header or object to the library. Thus, the cookies will be empty even if the user have some. You need to provide them in some way using Would you mind sharing your code or the portion dealing with cookies and SSR? |
@eXon I appreciate the work you've put in. Unfortunately, I've moved from universal rendering to just client side, so the |
I came across this issue when using Next.js for server side rendering. My solution was:
|
Still facing the same issue. Any solution ? |
@tamal-appsbee are you server side rendering? can u show your code where u get error? |
@kunokdev thanks for reply.
In store using following:
|
you are getting error at this line; |
Ok, |
I haven't used this approach, to me it seems it would be used inside routers where |
ok, Thanks |
Just to loop back, our solution was to just stub this object. |
@Brantron can you provide a code example of what you described above? |
Sorry @andrefox333 ! That would certainly have been helpful. We wrapped our cookie usage in a helper object and just stubbed access like
|
@eXon I am doing server side rendering and I would like to know if it's possible to get instance of the cookie object outside a component. I am getting the same errors as @andrefox333. I have a single util function and I want to know if I need to give the cookie from the component as a new argument at every call or I might be able to access it as a "global". |
@mmoustai You must pass the Cookies object as an argument. You cannot use a global variable otherwise you risk hijacking the cookies from another user. |
still having this issue. |
@mshavandi Do you have a step by step or repo to reproduce the issue? |
I am using
universal-cookie
and am experiencing this problem when instantiating it. I'm doing the same thing as the example:The text was updated successfully, but these errors were encountered: