erikras / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using express, react, redux, webpack, and react-transform
MIT License
12k stars 2.5k forks source link

How to check request cookies in server-side Redux action? #1258

Closed isaachinman closed 8 years ago

isaachinman commented 8 years ago

In our app, we store a JWT inside a secure cookie to do initial authentication and bounce away from logged-in routes if a user isn't logged in.

Basically, I want to check for this cookie inside the load function in src/redux/modules/auth.js.

The load function by default looks like this:

export function load() {
  return {
    types: [LOAD, LOAD_SUCCESS, LOAD_FAIL],
    promise: (client) => client.get('/loadAuth')
  }
}

Instead of calling to an endpoint, I just need to examine the request itself.

Sorry for posting a blatantly help-related issue, but I am having trouble figuring this out.

gabriel-miranda commented 8 years ago

Send other property, like checkCookie, and handle that in your middleware. Or use sagas to handle that in a prettier way.

isaachinman commented 8 years ago

@gabriel-miranda Sorry, could you expand more? Where would I send checkCookie, and what middleware?

Also, I came across reactGo, which is basically a fork of this project, except with sagas. Do you have any experience with it?