Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
middleware: () => next => async (action) => {
if (typeof window !== 'undefined') {
const token = cookie.get('token');
if (token) {
await cookie.set('token', token, 1);
}
}
// do something here
return next(action);
},
},
static async getInitialProps({ req, res, match, store, history, location }) {
let token = null;
// only on the server side
if (req && store.dispatch.global && store.dispatch.global.verify && req.cookies) {
token = req.cookies.token;
}
if (typeof window !== 'undefined') {
token = cookie.get('token');
}
await store.dispatch.global.verify({ token });
return { whatever: 'Home stuff', isServer: true };
}
render() {