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

React + Session #232

Closed
gonardfreeman opened this issue Nov 20, 2017 · 2 comments
Closed

React + Session #232

gonardfreeman opened this issue Nov 20, 2017 · 2 comments

Comments

@gonardfreeman
Copy link

gonardfreeman commented Nov 20, 2017

Hello guys, how to write cookie session to my react app, when i'm in developing mode? I'm syncing data via proxy.
In ideal I'm need to create session on my react app, because when I'm coping cookie to react and trying to read it on server app response with: "Cannot decrypt cookie value, create a new fresh session".

@asvetlov
Copy link
Member

Sorry, I don't use React and cannot figure out what is broken.
Could you pin down your problem?

@gonardfreeman
Copy link
Author

gonardfreeman commented Nov 20, 2017

@asvetlov I'm figure out where was problem) when you use create react app + proxy for fetching data from different url (ex. react at localhost:3000 and server at localhost:3001) for bypassing CORS and make some GET/POST requests, you need add additional param to your request credentials: 'include', so your fetch func in react, will look like this:

return fetch(`http://${MAINSITE}/login`, {
      method: 'POST',
      headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(data),
      credentials: 'include'
    })

it will pass cookies via proxy, because with out this there where no cookies in request param of view, so get_session(request) cannot read it.

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

2 participants