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.
sos-nextjs/utils/redirectGetInitialProps.js

15 lines
290 B
JavaScript

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")
}
}