You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
313 B
JavaScript

import Router from 'next/router'
export default function redirectGetInitialProps(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")
}
}