import Router from 'next/router' export default function (ctx, status, url) { const {res} = ctx if(res) { res.writeHead(status, {Location: url}) res.end(); } else if (window) { Router.push(url) } else { console.error("Could not redirect for unknown reason") } }