Skip to content
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

How to pass data from express req object to the req received by middleware #49

Open
ruslantalpa opened this issue Jun 9, 2017 · 3 comments

Comments

@ruslantalpa
Copy link

In case of server side rendering, i want to forward a particular header (Cookie) from the express request to the (fetch) req object (the one received by middleware). How can one do that? I don't think i can have the middleware function accessing some global var (race conditions).

Thanks

@nodkz
Copy link
Collaborator

nodkz commented Jun 10, 2017

Tricky question.

As you said, global var is the wrong solution. Don't use it for SSR.

I suppose that you should create network layer for every request. There is now way to pass request context to react-relay-network-layer.

I have not ready solution/example yet. So if you or somebody else make it working, please drop here an example for further googlers. Thanks.

@Blackening999
Copy link

so there's no way to set cookies???

@nodkz
Copy link
Collaborator

nodkz commented May 25, 2018

Cookies are set by browser automatically. Network Layer should not set cookies, this is not its task.

So if you don't have cookies in the browser after fetch, then you incorrectly prepared your server.

Also take a look on fetch spec, it has not only same-origin, may be in your case need to use other policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants