Closed papigers closed 8 years ago
You should not use fetch directly, but some factory which wraps fetch on the server. This factory should be injected for example in react context or relay environment
I'm not using fetch directly, relay does under the hood. It uses isomorphic fetch which uses node fetch on the server side, and regular fetch on the client's.
Aha :-)
I updated the README.
Hey, I've been using cookies for token-based authentication, as the source for my token. To include the token automatically, I use the known fetch option:
This works great for the client which uses the regular
fetch
which uses this option. but server-side usesnode-fetch
which doesn't knows this option and doesn't send the cookies automatically. This causes to the cookies to be missing on mygraphql-express
middleware.This is solvable using this ugly solution:
So basically every request I'm creating a new network layer with the cookies attached. Pretty ugly.
Nothing you can do really, but I guess it should be acknowleged.