How to use the react-cookie.setRawCookie function in react-cookie

To help you get started, we’ve selected a few react-cookie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lemonCMS / redux-form-generator / example / server / index.js View on Github external
app.use((req, res) => {
  cookie.plugToRequest(req, res);
  if (typeof(req.headers.cookie) !== 'undefined') {
    cookie.setRawCookie(req.headers.cookie);
  } else {
    // Force empty cookie
    cookie.setRawCookie('');
  }
  return App.default(req, res);
});
github lemonCMS / redux-form-generator / example / src / server.js View on Github external
app.use((req, res) => {
  if (__DEVELOPMENT__) {
    // Do not cache webpack stats: the script file would change since
    // hot module replacement is enabled in the development env
    webpackIsomorphicTools.refresh();
  }

  // There is some bug that keeps a cookie in memory while infact there was nog a cookie send.
  // So let see if request headers have a cookie,
  // If not reset cookie.
  cookie.plugToRequest(req, res);
  if (typeof(req.headers.cookie) !== 'undefined') {
    cookie.setRawCookie(req.headers.cookie);
  } else {
    // Force empty cookie
    cookie.setRawCookie('');
  }

  const token = cookie.load('locale');
  const locale = req.query.locale || token || 'nl';
  const messages = translations[locale];

  if (!messages) {
    return res.status(404).send('Locale is not supported.');
  }
  const i18n = {locale, messages};
  cookie.save('locale', locale);

  const client = new ApiClient(req);
  const store = createStore(reduxReactRouter, getRoutes, createHistory, client);
  listener(store);
  function hydrateOnClient() {
github Imater / 4redux / src / server.js View on Github external
app.use((req, res) => {
  if (__DEVELOPMENT__) {
    // Do not cache webpack stats: the script file would change since
    // hot module replacement is enabled in the development env
    webpackIsomorphicTools.refresh()
  }

  reactCookie.setRawCookie(req.headers.cookie)
  reactCookie.plugToRequest(req, res)

  const historyNotSync = createHistory(req.originalUrl)

  const store = createStore(historyNotSync, {
    userAgent: req.headers['user-agent']
  })
  const history = syncHistoryWithStore(historyNotSync, store)
  const assets = webpackIsomorphicTools.assets()

  // assets.styles.z_datePicker = `${config.prefix}/DatePicker.css` to add css to index.html

  function hydrateOnClient() {
    res.send(`\n
      ${renderToStaticMarkup()}`)
  }
github lemonCMS / redux-form-generator / example / src / server.js View on Github external
app.use((req, res) => {
  if (__DEVELOPMENT__) {
    // Do not cache webpack stats: the script file would change since
    // hot module replacement is enabled in the development env
    webpackIsomorphicTools.refresh();
  }

  // There is some bug that keeps a cookie in memory while infact there was nog a cookie send.
  // So let see if request headers have a cookie,
  // If not reset cookie.
  cookie.plugToRequest(req, res);
  if (typeof(req.headers.cookie) !== 'undefined') {
    cookie.setRawCookie(req.headers.cookie);
  } else {
    // Force empty cookie
    cookie.setRawCookie('');
  }

  const token = cookie.load('locale');
  const locale = req.query.locale || token || 'nl';
  const messages = translations[locale];

  if (!messages) {
    return res.status(404).send('Locale is not supported.');
  }
  const i18n = {locale, messages};
  cookie.save('locale', locale);

  const client = new ApiClient(req);
github xpepermint / isomorphic-react-flux-boilerplate / server / controllers / index.js View on Github external
function render(req, res, next) {
  // We use cookies to store accessToken. If the cookie exists it means that a
  // user is authenticated. We have to initialize the react-cookie package like
  // it would be initialized when running inside browser. This must be done
  // before running Router.run because authentication check is executed inside
  // onEnter method. We load cookies and patch methods which manipulate with
  // cookies.
  cookie.setRawCookie(req.headers.cookie);
  cookie.save = res.cookie.bind(res);

  let location = new Location(req.path, req.query);
  Router.run(routes, new Location(req.path, req.query), (error, state, transition) => {
    if (error) return next(error);
    // If the transaction is canceled it means that the router is redirecting to
    // a new route so we redirect a user.
    if (transition.isCancelled) return res.redirect(transition.redirectInfo.pathname);

    // Router.run moves to the first route. Flux doesn't have to be loaded
    // before Router.run. Here we already have router's state and we can easily
    // load initial data based on the components branch.
    AltBootstrap.run(state, req).then(snapshot => {
      Alt.bootstrap(snapshot);

      let markup = ReactDomServer.renderToString();
github lemonCMS / redux-form-generator / example / server / index.js View on Github external
app.use((req, res) => {
  cookie.plugToRequest(req, res);
  if (typeof(req.headers.cookie) !== 'undefined') {
    cookie.setRawCookie(req.headers.cookie);
  } else {
    // Force empty cookie
    cookie.setRawCookie('');
  }
  return App.default(req, res);
});